Skip to content

Install Go on Windows ​

Before You Start

  • Applies to: Go 1.21+ (examples verified with Go 1.22) · Prerequisites: Get Started · Read time: about 7 min

This guide will help you install Go language on Windows system.

Download Go ​

First, download the Go installation package suitable for your Windows system from the official website.

Choose the corresponding version based on your system architecture:

  • windows-amd64 - 64-bit Windows system
  • windows-386 - 32-bit Windows system
  • windows-arm64 - 64-bit ARM Windows system

Installation Methods ​

This is the simplest installation method, suitable for most users.

1. Download the installer ​

Download the .msi installation package from the official website.

2. Run the installer ​

Double-click the downloaded .msi file and follow the installer's prompts to complete the installation.

The installer will automatically:

  • Install Go to C:\Program Files\Go or C:\Program Files (x86)\Go
  • Configure the necessary environment variables

3. Verify installation ​

Open a new command prompt window (cmd) or PowerShell and execute:

powershell
go version

If the installation is successful, you should see output similar to:

go version go1.21.3 windows/amd64

Method 2: Using ZIP Archive ​

This method is suitable for users who need to manage multiple Go versions or install to a custom path.

1. Download the archive package ​

Download the .zip compressed package from the official website.

2. Extract to specified directory ​

Extract the downloaded .zip file to a specified directory, for example C:\Go.

3. Configure environment variables ​

You need to configure the following environment variables:

  1. Right-click "This PC" and select "Properties"
  2. Click "Advanced system settings"
  3. Click "Environment Variables"

Add the following environment variables:

GOROOT (Go installation directory):

C:\Go

GOPATH (Go workspace directory):

C:\Users\YourUsername\go

Add the following to the Path environment variable:

%GOROOT%\bin
%GOPATH%\bin

4. Restart command prompt ​

Close all command prompt windows and reopen them to make the environment variables take effect.

5. Verify installation ​

powershell
go version

Configure GOPATH ​

By default, Go uses %USERPROFILE%\go as the workspace directory. If you want to use a different path, you can set the GOPATH environment variable.

The GOPATH directory structure is as follows:

GOPATH/
├── bin/    # Stores compiled executable files
├── pkg/    # Stores compiled package files
└── src/    # Stores source code

Verify Installation ​

Create a simple Go program to verify that the installation is successful:

1. Create project directory ​

powershell
mkdir C:\Users\YourUsername\hello
cd C:\Users\YourUsername\hello

2. Create Go program file ​

Create a file named hello.go with the following content:

go
package main

import "fmt"

func main() {
    fmt.Println("Hello, World!")
}

3. Run the program ​

powershell
go run hello.go

If the output is Hello, World!, it means the installation is successful.

Uninstall ​

Uninstall MSI Installer Version ​

If you installed Go using the MSI installer:

  1. Open "Control Panel" > "Programs and Features"
  2. Find "Go Programming Language" in the program list
  3. Right-click and select "Uninstall"

Uninstall ZIP Archive Version ​

If you installed Go using the ZIP archive:

  1. Delete the Go installation directory (e.g., C:\Go)
  2. Remove the Go-related environment variables from the environment variables settings

Troubleshooting ​

Command not found ​

If the go command is not found, please check:

  1. Whether the PATH environment variable is configured correctly
  2. Whether the environment variables have taken effect (restart command prompt)
  3. Check if the Go installation directory exists

Version mismatch ​

If the displayed version does not match the installed version, please check:

  1. Whether there are multiple Go installations
  2. Whether the PATH environment variable points to the correct Go installation directory
  3. Execute where go to view the actual path of the go command

Permission denied ​

If you encounter a permission denied error:

  1. Run command prompt as administrator
  2. Check if you have write permissions to the installation directory

Module proxy issues ​

If you encounter issues downloading modules, you can configure a module proxy:

powershell
go env -w GOPROXY=https://goproxy.cn,direct

Using PowerShell ​

It is recommended to use PowerShell instead of cmd, as PowerShell provides better command-line experience.

Check environment variables ​

powershell
$env:GOROOT
$env:GOPATH
$env:PATH

Set environment variables (temporary) ​

powershell
$env:GOROOT = "C:\Go"
$env:GOPATH = "C:\Users\YourUsername\go"
$env:PATH += ";$env:GOROOT\bin;$env:GOPATH\bin"

Set environment variables (permanent) ​

To permanently set environment variables in PowerShell, you can use the [System.Environment] class:

powershell
[System.Environment]::SetEnvironmentVariable("GOROOT", "C:\Go", "User")
[System.Environment]::SetEnvironmentVariable("GOPATH", "C:\Users\YourUsername\go", "User")

Next Steps ​

After installation is complete, you can:

  • IDE: GoLand (paid), Visual Studio Code (free)
  • Terminal: Windows Terminal, PowerShell 7+
  • Package Manager: Chocolatey, Scoop (can be used to install Go)

Installing Go using Chocolatey ​

powershell
choco install golang

Installing Go using Scoop ​

powershell
scoop install go

Complete Example ​

After installing, use the program below to verify the toolchain from the command line. Copy it into a file and run go run main.go.

go
package main

import (
	"fmt"
	"os/exec"
	"runtime"
	"strings"
)

func main() {
	out, err := exec.Command("go", "version").Output()
	fmt.Println("go command found in PATH:", err == nil)
	fmt.Println("version output starts with go:", err == nil && strings.HasPrefix(string(out), "go"))
	fmt.Println("GOROOT is set:", runtime.GOROOT() != "")
}

Expected output:

text
go command found in PATH: true
version output starts with go: true
GOROOT is set: true

Common Pitfalls ​

  • Open a new terminal after installing. Shells opened before the installer updated PATH cannot find go.
  • Check for duplicate installations. Run where.exe go; an old MSI plus a fresh scoop/choco install will shadow each other.
  • Uninstall the old version first. Otherwise GOROOT may still point at the previous directory.
  • Leave GOROOT alone. The installer sets it correctly; only override it for custom layouts.
  • Prefer one package manager. Mixing MSI, Chocolatey and Scoop upgrades creates hard-to-debug conflicts.

Change Log ​

  • 2026-10-14: Added "Before You Start" notes, a complete runnable example with expected output, common pitfalls, and this change log.

Golang by www.golangdev.cn · Adapted in part from Golang 中文学习文档 (MIT, © 寒江蓑笠翁)