Installing Go

An overview of the available methods for installing Go on your system - precompiled binary distributions, building from source, and managing multiple versions

Before you can write, compile, or run any Go program, the Go toolchain must live somewhere on your machine. This toolchain includes the go command, the compiler, the linker, the standard library, and a collection of tools like gofmt and go vet. The way you install it depends on your operating system, how much control you need over the build process, and whether you plan to juggle more than one Go version.

This page outlines the three installation paths and what each one is best for. For step‑by‑step instructions, follow the links to the dedicated subpages.

Installation Methods at a Glance

Three primary ways exist to get Go onto your system.

MethodWhat it meansWho should use it
Precompiled binary distributionsDownload a platform‑specific archive or installer from the official Go website and unpack it.Nearly everyone. This is the fastest, most reliable path for Linux, macOS, and Windows.
Installing from sourceClone the Go source repository and build the toolchain yourself with a C compiler.Contributors to Go itself, people on exotic platforms with no prebuilt binaries, and anyone who needs to test the latest unreleased development branch.
Managing multiple Go versionsRun two or more Go toolchains side by side and switch between them on demand.Developers maintaining projects that still target older Go releases, or teams that want to test against multiple compiler versions before upgrading.

Each approach has its own subpage in this section. The rest of this page gives you the context to choose the right one.

Precompiled Binary Distributions

If you have never installed Go before, start here.

The Go team builds and tests official binaries for all major operating systems and architectures. You download a .tar.gz file (Linux/macOS) or an .msi installer (Windows), unpack it into a directory like /usr/local/go, and add the go binary to your system PATH. After that, go version should print the version you just installed.

Linux users on Debian‑based distributions can also install Go through apt, and Ubuntu users can use a snap. Those are perfectly fine options — they just might lag behind the latest official release by a few weeks.

Remove any previous Go installation first:

Never unpack a new Go archive directly over an existing /usr/local/go directory. Delete the old tree first (rm -rf /usr/local/go). Failing to do that can leave behind stale binaries and produce a broken toolchain.

The subpage “Downloading Official Binary Distributions” walks through the exact commands for Linux, macOS, and Windows, including how to set the PATH persistently and how to avoid the most common permission mistakes.

Installing from Source

Building Go from source is a deliberate choice, not a casual one.

The process requires a working C compiler (GCC or Clang) and a bootstrapping Go toolchain — ironically, you need Go to compile Go. The source repository contains a rich test suite that you can run before installation to verify your build.

This path is documented fully in the subpage “Installing from Source.” It covers cloning the repository, selecting the branch or tag you want, and running the build scripts. The result is a custom Go toolchain that lives wherever you put it and can be fine‑tuned with compiler flags.

When source installs make sense:

The most common reason to build from source is contributing to the Go project itself. If you are just learning the language, stick with the precompiled binary — it will save you time and frustration.

Managing Multiple Go Versions

A single machine rarely needs more than one Go version, until it does.

Maybe your CI pipeline tests against Go 1.21, 1.22, and 1.23. Maybe a legacy project refuses to compile with a newer compiler. Maybe you want to preview an upcoming release candidate without touching your daily‑driver installation. In all these cases, you need a way to install several toolchains and point your terminal at the right one.

The subpage “Managing Multiple Go Versions” details the official go install golang.org/dl/... mechanism, which downloads a version‑specific wrapper, as well as the older technique of keeping separate installation directories and swapping symlinks. It also explains how to isolate per‑project toolchains using the go directive in go.mod so that you rarely need to switch manually.

Verifying the Installation

Regardless of the method you chose, one command tells you whether everything worked.

go version

If the output shows the expected version string — something like go version go1.26.4 linux/amd64 — then the go binary is on your PATH and talking to the rest of the toolchain correctly.

Installation complete:

When go version prints a valid version without errors, the installation is finished. You can now compile, test, and run Go programs.

If you see “command not found,” the PATH was not updated properly. Revisit the platform‑specific instructions and make sure the directory containing the go binary was added to your shell’s configuration file (.bashrc, .profile, .zshrc, or the system‑wide equivalent). After editing the file, open a new terminal or run source on it.