Skip to content

Install Go

go-zero requires Go 1.21 or later. This page shows how to install Go on macOS, Linux, and Windows, and how to verify the setup.

Terminal window
go version
# go version go1.23.4 linux/amd64

If the version is ≥ 1.21, skip to Validate Environment. Otherwise install or upgrade below.

Terminal window
# Using Homebrew (recommended)
brew install go
# Or download the .pkg installer from:
# https://go.dev/dl/
Terminal window
# Download and extract (replace 1.23.4 with the latest)
wget https://go.dev/dl/go1.23.4.linux-amd64.tar.gz
sudo rm -rf /usr/local/go
sudo tar -C /usr/local -xzf go1.23.4.linux-amd64.tar.gz

Add Go to your shell profile (~/.bashrc, ~/.zshrc, etc.):

Terminal window
export PATH=$PATH:/usr/local/go/bin
export GOPATH=$HOME/go
export GOBIN=$GOPATH/bin
export PATH=$PATH:$GOBIN

Reload:

Terminal window
source ~/.zshrc # or ~/.bashrc

Download and run the .msi installer from go.dev/dl. The installer updates PATH automatically.

Terminal window
go version
# go version go1.23.4 ...
go env GOPATH GOBIN GOMODCACHE
# /home/user/go
# /home/user/go/bin
# /home/user/go/pkg/mod

Make sure GOBIN is in your PATH — this is where goctl and other Go-installed binaries live.

ProblemFix
go: command not foundAdd /usr/local/go/bin to PATH and reload shell
goctl: command not found after installAdd $GOBIN to PATH
Module download errorsRun go env -w GOPROXY=https://goproxy.cn,direct (China)

Install goctl →