Install Go and GCCgo on Ubuntu
This is an updated version of my 2025 installation note. The PPA and pinned versions in the original instructions are no longer a good default: Ubuntu’s Go and GCCgo package versions depend on the release. Ordinary Go cross-compilation generally needs the Go toolchain, not GCCgo. See the official Go installation guide and GCCgo guide.
I had just started learning Go and wanted to cross-compile on Linux. The process seemed complicated, so I wrote down what I had tried. I installed GCCgo but did not successfully compile my project with it.
Install Go
First check the Go package available in your Ubuntu release:
sudo apt update
apt-cache policy golang-go
If the repository version meets your needs, install the Ubuntu package and verify it:
sudo apt install golang-go
go version
If you need a newer upstream release, use the official Go download and installation instructions. The version and install path change over time, so do not reuse a version-specific path from an old article.
For common cross-compilation targets, Go’s built-in GOOS and GOARCH settings are usually sufficient. GCCgo is a separate compiler and is not required for ordinary Go cross-compilation.
Install GCCgo only if you need it
Package names are tied to the GCC version shipped by your Ubuntu release. Search the current package index first:
apt-cache search '^gccgo-[0-9]+$'
Install the matching versioned package shown by your system, then check the corresponding gccgo-<version> command. Do not copy the old gccgo-14 package name without checking that it exists for your release.
In my original experiment, I installed GCCgo but did not get my own project to compile with it. For compatibility and invocation details, start with the GCCgo documentation.
Check the executable path
When Go is installed from Ubuntu packages, check the executable that is on your path:
command -v go
go version
If you install Go manually, follow the official guide’s instructions for adding its bin directory to PATH. Avoid hard-coding an old versioned path such as /usr/lib/go-1.24/bin into a new installation.