This is useful when you need a specific version, want to test patches, or contribute to the Go project itself.
Why Install from Source?
- You need a version not yet available as a binary release
- You want to apply or test a patch before it ships
- You’re contributing to the Go compiler or standard library
- You want to understand the Go toolchain internals
How It Works
The Go team manages releases based on tags (versions). You can check out a specific version and install it from source.
Since Go 1.15, Go uses a Go compiler, meaning it compiles itself. If you already have Go installed, you can use it to compile a newer version, as long as the version gap is within two major releases.
Steps
Clone the source from go.googlesource.com/go (the canonical repository). The GitHub mirror mainly holds the master branch and is primarily for contributors.
Check out the version tag you want:
git clone https://go.googlesource.com/go
cd go
git checkout go1.23.0
- Build from the
srcdirectory:
cd src
./all.bash
This runs the build and all tests. Use ./make.bash if you want to skip tests.
- Add to your PATH:
export PATH=$HOME/go/bin:$PATH
Key Points
- You need an existing Go installation (within two major versions) to bootstrap the build
- The build takes a few minutes depending on your hardware
all.bashruns both the build and the full test suite
For the full guide, see the official docs: go.dev/doc/install/source