Download the official .msi installer from golang.org and run it with administrative privileges to add Go to your system PATH automatically. Once installed, verify the setup by running go version in a new Command Prompt or PowerShell window to ensure the environment is correctly configured.
The most reliable method is using the graphical installer provided by the Go team. Navigate to the "Downloads" section on the official website, select the Windows MSI installer for your architecture (usually go1.22.x.windows-amd64.msi), and double-click to run it. The installer defaults to C:\Go, which is the standard location, and automatically updates your system environment variables. Do not skip the "Add Go to PATH" option during the setup wizard, as this is critical for running commands from any directory.
If you prefer a manual approach or need to install a specific version not yet on the main download page, you can download the .zip archive, extract it to C:\Go, and manually add C:\Go\bin to your system PATH. To do this manually, right-click "This PC," select "Properties," click "Advanced system settings," and then "Environment Variables." Under "System variables," find the Path entry, click "Edit," and add a new entry pointing to C:\Go\bin.
After installation, always open a new terminal window to load the updated environment variables. Verify the installation with the following commands:
# Check the installed version
go version
# Initialize a new module to test the toolchain
go mod init myapp
If go version returns "is not recognized," your terminal hasn't picked up the new PATH variable. Close and reopen your terminal, or run refreshenv in PowerShell to reload the environment without restarting.
For developers who frequently switch between Go versions, consider using gvm (Go Version Manager) or goenv after the initial installation. These tools allow you to install multiple versions and switch between them via command line, which is useful when working on legacy projects or testing compatibility. However, for most standard workflows, the official MSI installer remains the simplest and most stable solution.
# Example: Creating a simple 'Hello World' program to verify full functionality
echo 'package main
import "fmt"
func main() {
fmt.Println("Go is working on Windows!")
}' > main.go
go run main.go
If you encounter permission errors when running go install, ensure your user account has write permissions to the C:\Users\<YourUser>\go directory, which is the default GOPATH. The installer sets this up correctly by default, but antivirus software or strict corporate policies might sometimes block the creation of these directories.