Set up a Go development environment on Windows with Visual Studio Code (VS Code).
-
Visit the official website of VS Code and click Download for Windows to download the installation file.

-
Double-click the downloaded file such as VSCodeUserSetup-x64-1.89.1.exe and use the installation wizard to install VS Code.
ImportantIn the Select Additional Tasks step, you must select Add to PATH (requires shell restart).
-
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.

-
-
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.
-
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.modfile is generated in the project directory to manage dependencies and versions.
-
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") } -
Run the code.
-
If Code Runner is installed, right-click in the editor and select Run Code.

-
Run the
go runcommand in the Terminal.
-
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.
-
-
Verify the setup.
Check the console output. If
hello aliyun!appears, the Go development environment is ready.