Skip to content
Commitpedia
Log in Join & edit

Install Go on Linux, macOS and Windows

Install the Go toolchain from the official downloads or a package manager, set PATH so the go command and installed tools are found, and verify with go version.

Drafted with AI from official documentation. Scripts were run in a test environment and repository links verified. Awaiting a human check. Did it work for you? Last edited Outdated?

Edit history of Install Go on Linux, macOS and Windows: 1 recorded edit
Edit history · 1 edit
Type
Article
Edits
1
Editors
1
First issued
15 Oct 2026
Last edit
15 Oct 2026
Reading
2 min

Which option to pick

Go ships as a single self-contained toolchain, and the official archives from go.dev/dl are the recommended install on every OS. Package managers are convenient on macOS (Homebrew keeps up to date) and Windows (winget), but Linux distribution packages often lag several releases, and Go projects commonly require the latest two. Since Go 1.21 the go command can also download a newer toolchain by itself when a module’s go.mod asks for one, so a slightly older install is less of a problem than it used to be.

Step: Linux

Pick the current linux-amd64 (or linux-arm64) archive on the download page, then replace the file name below. The commands remove any previous Go in /usr/local/go and unpack the new one in its place.

Check before you run this

  • Deletes files and folders without asking. Check the path before running.
  • Runs with administrator rights. Make sure you understand every line.
curl -LO https://go.dev/dl/go1.27.2.linux-amd64.tar.gz
sudo rm -rf /usr/local/go
sudo tar -C /usr/local -xzf go1.27.2.linux-amd64.tar.gz
echo 'export PATH=$PATH:/usr/local/go/bin' >> ~/.profile
source ~/.profile

Careful: rm -rf /usr/local/go deletes the previous Go installation. That is the intended upgrade path; do not unpack a new version on top of an old one. Do not use /usr/local/go for anything else.

Step: macOS

brew install go

Or download the .pkg installer from go.dev/dl, which installs to /usr/local/go and adds it to PATH. Open a new terminal afterwards.

Step: Windows

winget install GoLang.Go

Or run the .msi installer from go.dev/dl. Both install to C:\Program Files\Go and update PATH. Open a new terminal window so the change takes effect.

Check it works

go version
go env GOPATH

Tools you install with go install example.com/tool@latest land in $(go env GOPATH)/bin, which is ~/go/bin by default. Add that directory to your PATH as well:

echo 'export PATH="$PATH:$(go env GOPATH)/bin"' >> ~/.profile

A first program to confirm compiling works:

mkdir hello && cd hello
go mod init example.com/hello
cat > main.go <<'EOF'
package main

import "fmt"

func main() {
	fmt.Println("hello from go")
}
EOF
go run .

Common problems

  • go: command not found after installing on Linux: PATH is only read when a shell starts. Open a new terminal, or check that the export line went into the file your shell actually reads (.profile, .bashrc or .zshrc).
  • An old version from apt install golang shadows the new one: run which -a go to see both and remove the distribution package, or make sure /usr/local/go/bin comes first in PATH.
  • go: go.mod requires go >= 1.xx: the project needs a newer toolchain. Upgrade using the same steps, or let Go fetch it automatically if GOTOOLCHAIN is left at its default auto.
  • Installed tools not found: ~/go/bin is not on PATH; see the step above.

Official documentation

Did this work for you?

No votes yet. Be the first.

If it did not work, the report form below tells the editors what went wrong.

See also

  • 0386 Install Node.js on Linux, macOS and Windows Get Node.js and npm on any desktop OS. Use a version manager (nvm or fnm) when you work on several projects, or… Beginner · Step by step · Linux, macOS, Windows Article Installing languages & tools · Node.js 15 Oct 2026
  • 0387 Install Python on Linux, macOS and Windows Install a current Python 3 with pip and venv on each desktop OS, check the version, and avoid the classic traps: python… Beginner · Step by step · Linux, macOS, Windows Article Environments & packages · Installing languages & tools 15 Oct 2026
  • 0389 Install Java (OpenJDK) on Linux, macOS and Windows Install a current long-term-support OpenJDK with the compiler included, make java and javac available on the command line, and switch between versions… Beginner · Step by step · Linux, macOS, Windows Article Installing languages & tools 15 Oct 2026
  • 0390 Install Git on Linux, macOS and Windows Install Git from your package manager, Xcode's command line tools or the Windows installer, confirm the version, and do the one-time configuration… Beginner · Step by step · Linux, macOS, Windows Article Installing languages & tools · Setup 15 Oct 2026
  • 0391 Install Docker on Linux, macOS and Windows Docker Desktop or Docker Engine? Pick the right one for your OS, install it, and confirm with docker run hello-world. Covers the… Beginner · Step by step · Linux, macOS, Windows Article Docker basics · Installing languages & tools 15 Oct 2026
  • 0392 Install Visual Studio Code on Linux, macOS and Windows Install VS Code from Microsoft's packages, Homebrew or winget, get the code command working in the terminal, and add the extensions you… Beginner · Step by step · Linux, macOS, Windows Article Command-line tools · Installing languages & tools 15 Oct 2026

History

Every saved edit is kept. The plot on the sleeve draws one line per edit. Open any edit to see exactly what changed.

  1. Dominik +2,859 chars

Report a problem

Something wrong, unsafe or copied? Tell the editors.
What is wrong?