All Products
Search
Document Center

Alibaba Cloud SDK:Set up a Go development environment on Windows

Last Updated:Aug 26, 2026

Set up a Go development environment on Windows with Visual Studio Code (VS Code).

  1. Go to the VS Code official website and click Download for Windows to download the installation file.

  2. Double-click the downloaded file, such as VSCodeUserSetup-x64-1.89.1.exe, and follow the installation wizard to install VS Code.

    Important

    In the Select Additional Tasks step, you must select Add to PATH (requires shell restart).

  3. Open VS Code. In the left sidebar, click Extensions or press Ctrl+Shift+X. Install the following extensions:

    • Go: The official Go extension. Provides code editing, intelligent completion, and debugging.

    • Code Runner: Runs code directly in the editor with a single click. Supports multiple languages including Go, Python, C++, Java, PHP, and Node.js.

  4. Create a Go project.

    In the VS Code menu bar, click File > Open Folder. Create a new project folder, such as goProjects, and then select the folder.

  5. Initialize the Go module.

    In the VS Code menu bar, click Terminal > New Terminal. Run `go mod init goprojects` to initialize the module. A go.mod file is generated in the project directory to manage dependencies and versions.

    PS D:\ide\projects\goprojects> go mod init goprojects
    go: creating new go.mod: module goprojects
    PS D:\ide\projects\goprojects>
  6. Create a .go file. To the right of the project name, click New File..., enter a file name such as helloaliyun.go, and paste the following code:

    package main
    
    import (
    	"fmt"
    )
    
    func main() {
    	fmt.Println("hello aliyun")
    }
  7. Run the code.

    • If Code Runner is installed, right-click in the editor and select Run Code.

      Output:

      [Running] go run "d:\ide\projects\goprojects\helloaliyun.go"
      hello aliyun
      
      [Done] exited with code=0 in 1.95 seconds
    • Run the go run command in the Terminal.

      package main
      
      import (
          "fmt"
      )
      
      func main() {
          fmt.Println("hello aliyun")
      }
      PS D:\ide\projects\goprojects> go run ./helloaliyun.go
      hello aliyun
    • Select the file to run, such as helloaliyun.go. In the left sidebar, click Run and Debug or press Ctrl+Shift+D, then click Run and Debug.

      helloaliyun.go file content:

      package main
      
      import (
          "fmt"
      )
      
      func main() {
          fmt.Println("hello aliyun")
      }

      DEBUG CONSOLE output:

      Starting: D:\ide\projects\bin\dlv.exe dap --listen=127.0.0.1:61046 from d:\ide\projects\goprojects
      DAP server listening at: 127.0.0.1:61046
      Type 'dlv help' for list of commands.
      hello aliyun
      Process 22080 has exited with status 0
      Detaching
  8. Verify the setup.

    Check the console output. If hello aliyun! appears, the Go development environment is ready.