Install Go
Before You Start
- Applies to: Go 1.21+ (examples verified with Go 1.22) · Prerequisites: Get Started · Read time: about 8 min
This guide will help you install Go language on different operating systems.
Choose Your Operating System
Select the operating system you are using:
System Requirements
Before installing Go, please ensure your system meets the following minimum requirements:
Windows
- Windows 7 or later
- 64-bit or 32-bit processor
macOS
- macOS 10.13 (High Sierra) or later
- Intel or Apple Silicon processor
Linux
- Any mainstream Linux distribution
- 64-bit or 32-bit processor
Download Go
Visit the official download page to download the Go installation package suitable for your system.
Installation Overview
The Go installation process is simple and straightforward:
- Download: Download the installation package suitable for your system
- Install: Follow the installation wizard or extract the archive
- Configure: Set up environment variables (GOROOT, GOPATH, PATH)
- Verify: Run
go versionto verify the installation
Environment Variables
After installation, you may need to configure the following environment variables:
GOROOT
Specifies the Go installation directory. By default:
- Windows:
C:\Go - macOS/Linux:
/usr/local/go
GOPATH
Specifies the Go workspace directory. By default:
- Windows:
%USERPROFILE%\go - macOS/Linux:
$HOME/go
PATH
Add the following to the PATH environment variable:
%GOROOT%\binor$GOROOT/bin%GOPATH%\binor$GOPATH/bin
Verify Installation
After installation is complete, open a terminal or command prompt and execute:
go versionIf the installation is successful, you should see output similar to:
go version go1.21.3 windows/amd64Next Steps
After installation is complete, you can:
- Learn Go basics: Visit Go Getting Started Guide
- Write your first program: Create a simple Hello World program
- Explore the standard library: Learn about Go's rich standard library
- Join the community: Participate in the Go community and get help
Troubleshooting
If you encounter issues during installation, please check:
- System compatibility: Ensure your system meets the minimum requirements
- Permissions: Ensure you have sufficient permissions to install software
- Environment variables: Ensure environment variables are configured correctly
- Network connection: Ensure you can access the Go official website
For more detailed troubleshooting information, please visit the installation guide for your specific operating system.
Additional Resources
Complete Example
After installing Go, use the program below to verify the toolchain works. Copy it into a file and run go run main.go, or paste it into the Go Playground.
package main
import (
"fmt"
"runtime"
"strings"
)
func main() {
v := runtime.Version()
fmt.Println("version:", v)
fmt.Println("is a Go 1.x release:", strings.HasPrefix(v, "go1."))
fmt.Println("toolchain works:", runtime.NumCPU() > 0)
}Expected output (the version line shows what you installed, so the number will differ):
version: go1.22.5
is a Go 1.x release: true
toolchain works: trueCommon Pitfalls
- Windows needs a new terminal. The
gocommand is not found in shells that were open before the installer updatedPATH. - macOS/Linux need PATH edits. Add Go's
bindirectory to~/.zshrcor~/.bash_profileand reload it withsource. - Multiple versions can shadow each other. Use
which -a go(macOS/Linux) orwhere.exe go(Windows) to see which one runs first. - Avoid
sudo go. Caches and modules written as root cause permission errors later. - Corporate networks may need proxies. Set
GOPROXY(andGOPRIVATEfor internal repositories) withgo env -w.
Change Log
- 2026-10-14: Added "Before You Start" notes, a complete runnable example with expected output, common pitfalls, and this change log.
