Skip to content

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:

  1. Download: Download the installation package suitable for your system
  2. Install: Follow the installation wizard or extract the archive
  3. Configure: Set up environment variables (GOROOT, GOPATH, PATH)
  4. Verify: Run go version to 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%\bin or $GOROOT/bin
  • %GOPATH%\bin or $GOPATH/bin

Verify Installation ​

After installation is complete, open a terminal or command prompt and execute:

bash
go version

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

go version go1.21.3 windows/amd64

Next Steps ​

After installation is complete, you can:

  1. Learn Go basics: Visit Go Getting Started Guide
  2. Write your first program: Create a simple Hello World program
  3. Explore the standard library: Learn about Go's rich standard library
  4. Join the community: Participate in the Go community and get help

Troubleshooting ​

If you encounter issues during installation, please check:

  1. System compatibility: Ensure your system meets the minimum requirements
  2. Permissions: Ensure you have sufficient permissions to install software
  3. Environment variables: Ensure environment variables are configured correctly
  4. 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.

go
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):

text
version: go1.22.5
is a Go 1.x release: true
toolchain works: true

Common Pitfalls ​

  • Windows needs a new terminal. The go command is not found in shells that were open before the installer updated PATH.
  • macOS/Linux need PATH edits. Add Go's bin directory to ~/.zshrc or ~/.bash_profile and reload it with source.
  • Multiple versions can shadow each other. Use which -a go (macOS/Linux) or where.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 (and GOPRIVATE for internal repositories) with go 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.

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