Last updated:
Quick answer: run sudo apt install golang-go to install the Go version that ships with your Ubuntu release (Go 1.26 on Ubuntu 26.04, Go 1.22 on Ubuntu 24.04). If you need the newest Go release, download the Linux archive from go.dev/dl, extract it into /usr/local and add /usr/local/go/bin to your PATH, or install the snap with sudo snap install go --classic. Check the result with go version.
| Method | Ubuntu 26.04 (resolute) | Ubuntu 24.04 (noble) | Updates |
|---|---|---|---|
golang-go (APT) |
Go 1.26 (golang-defaults 2:1.26~1) | Go 1.22.2 (golang-go 2:1.22~2build1) | With apt upgrade, same minor version |
Versioned package, e.g. golang-1.26-go |
1.26.8 in resolute-updates | 1.26.8 in noble-updates | With apt upgrade |
| Official tarball from go.dev | Go 1.27.4 (current stable on go.dev, checked 11 Nov 2026) | Manual: download and extract again | |
Snap (go --classic) |
1.27.4 in latest/stable (Snap Store, 11 Nov 2026) | Automatic snap refreshes | |
Go (often called Golang) is Google’s open-source programming language. You only need one of the methods below. Use APT if the packaged version is new enough for your project, and use the official tarball when a project’s go.mod asks for a newer Go than Ubuntu ships. The package versions above were read from the Ubuntu archive (Launchpad for 26.04, apt-cache policy for 24.04). The APT commands, the test program and the PATH setup were run on Ubuntu 24.04 on 11 Nov 2026. They were not run on a 26.04 machine, but the package names and paths are the same there. The screenshots in this guide come from the original 2024 version of the article on Ubuntu 24.04.
Method 1: Install Go from the Ubuntu repositories (APT)
This is the simplest method and the packages get security updates through the normal Ubuntu update process. First refresh the package lists:
sudo apt update

Then install the golang-go package. It is a small package that points /usr/bin/go at the default Go version for your release:
sudo apt install golang-go

Check the version. You do not need sudo for this or for any other go command in this guide:
go version
On Ubuntu 24.04 the output in our test was:
go version go1.22.2 linux/amd64

Need a newer Go on Ubuntu 24.04? Use a versioned package
Ubuntu 24.04 also carries newer Go toolchains as separate packages named golang-1.XX-go (1.23, 1.24, 1.25 and 1.26 were available in noble-updates when this was checked). They install next to the default version under /usr/lib/go-1.XX and do not change /usr/bin/go, so you have to put their bin folder first in your PATH:
sudo apt install golang-1.26-go
echo 'export PATH=/usr/lib/go-1.26/bin:$PATH' >> ~/.profile
source ~/.profile
go version
Before and after changing PATH in our test, the same terminal showed:
$ go version
go version go1.22.2 linux/amd64
$ export PATH=/usr/lib/go-1.26/bin:$PATH
$ go version
go version go1.26.8 linux/amd64
$ which go
/usr/lib/go-1.26/bin/go
Test the installation with a small program
Modern Go projects are modules, so create a folder with a go.mod file first:
mkdir ~/hello && cd ~/hello
go mod init example.com/hello
nano hello.go

Paste this program and save the file (Ctrl+O, Enter, Ctrl+X). Keep the opening brace on the same line as func main(); Go does not compile it otherwise (see the troubleshooting table below):
package main
import "fmt"
func main() {
fmt.Println("Hello from Go on Ubuntu")
}

Run it, then build a standalone binary:
go run .
go build -o hello
./hello
Output from our Ubuntu 24.04 test with Go 1.22.2:
$ go mod init example.com/hello
go: creating new go.mod: module example.com/hello
go: to add module requirements and sums:
go mod tidy
$ go run .
Hello from Go on Ubuntu
$ go build -o hello && ./hello
Hello from Go on Ubuntu

Method 2: Install the latest Go from go.dev with wget (official tarball)
This is the method the Go project documents on go.dev/doc/install. It always gives you the newest release, and it works the same on Ubuntu 26.04 and 24.04. Check go.dev/dl for the current file name; at the time of writing it was go1.27.4.linux-amd64.tar.gz (use linux-arm64 on ARM machines, and uname -m shows which one you have).
cd /tmp
wget https://go.dev/dl/go1.27.4.linux-amd64.tar.gz

Compare the checksum with the SHA256 value listed next to the file on go.dev/dl. For go1.27.4.linux-amd64.tar.gz it is 7226736c2339719cda28fbf3a54d71aa63bcefe376e98cef00034268dab24840:
sha256sum go1.27.4.linux-amd64.tar.gz
Now remove any earlier tarball install and extract the new one into /usr/local. The Go documentation warns that extracting over an existing /usr/local/go tree produces a broken installation, so always delete the old folder first. This only removes Go itself, not your projects in ~/go or elsewhere:
sudo rm -rf /usr/local/go
sudo tar -C /usr/local -xzf go1.27.4.linux-amd64.tar.gz

The older version of this guide extracted the archive on the Desktop and copied its path into a GOROOT variable, as the next screenshots show. That still runs, but it is not needed: when Go lives in /usr/local/go it finds its own files, and you only have to add it to PATH. If you want to see what is inside the tree, our guide to extracting tar.gz files explains how to list an archive before unpacking it.


Open ~/.profile:
nano ~/.profile

Add these two lines at the end of the file. The first makes the go command available, the second makes programs you install with go install (they land in ~/go/bin) available too:
export PATH=/usr/local/go/bin:$PATH
export PATH="$PATH:$HOME/go/bin"

Why /usr/local/go/bin goes first: go.dev appends it to the end of PATH. That is fine on a clean system, but if golang-go from APT is also installed, the older /usr/bin/go wins. In our test with both installed, appending gave /usr/bin/go (go1.22.2), while putting /usr/local/go/bin first gave the tarball version. Either remove the APT package or put the tarball first, as above.
Load the new settings in the current terminal (new terminals and logins read ~/.profile automatically):
Stuck at this step? Ask us, it is free and include the exact error.
source ~/.profile

Confirm which go runs and its version:
type -a go
go version
With both an APT Go and a Go tree in /usr/local/go (Go 1.24.7 on our test system), the output after the profile change was:
go is /usr/local/go/bin/go
go is /usr/bin/go
go is /bin/go
go version go1.24.7 linux/amd64

To upgrade later, download the newer archive and repeat the rm and tar commands; your PATH lines stay the same.
Method 3: Install Go with Snap
Canonical publishes Go as a classic snap, which refreshes automatically. Classic confinement means the snap can read and write files anywhere like a normal program, which a compiler needs:
sudo snap install go --classic

To stay on one minor version instead of following the newest release, pick a channel, for example sudo snap install go --channel=1.26/stable --classic. snap info go lists the channels. Then check the version (the snap install was not re-run for this update; the Snap Store listed 1.27.4 in latest/stable on 11 Nov 2026):
go version

If go version still shows an older version after installing the snap, another Go is earlier in your PATH; type -a go lists every copy (the snap one is in /snap/bin). Test it the same way as in Method 1:
nano gosample.go

package main
import "fmt"
func main() {
fmt.Println("Installing Go using the snap")
}

go run gosample.go

Method 4: Download the tarball with curl instead of wget
If you prefer curl, only the download step changes. Install curl if it is missing:
sudo apt install curl

Then download with -L (follow the go.dev redirect to dl.google.com) and -O (keep the file name), and continue with the checksum, rm, tar and PATH steps from Method 2:
cd /tmp
curl -LO https://go.dev/dl/go1.27.4.linux-amd64.tar.gz
sha256sum go1.27.4.linux-amd64.tar.gz
sudo rm -rf /usr/local/go
sudo tar -C /usr/local -xzf go1.27.4.linux-amd64.tar.gz
If you add the PATH line with echo instead of an editor, use single quotes so that $PATH is written literally and expanded each time you log in:
echo 'export PATH=/usr/local/go/bin:$PATH' >> ~/.profile
echo 'export PATH="$PATH:$HOME/go/bin"' >> ~/.profile
source ~/.profile


Run a test program and check the version:

go version

Troubleshooting
| Symptom | Cause | Fix |
|---|---|---|
go: command not found |
/usr/local/go/bin is not in PATH, or the profile was not reloaded |
Check the lines in ~/.profile, run source ~/.profile or log out and back in |
go version shows an older version than you installed |
Another Go (often /usr/bin/go from APT) comes first in PATH |
Run type -a go; remove the other copy or put the one you want first in PATH |
syntax error: unexpected semicolon or newline before { |
The opening brace of a function is on its own line. Go inserts a semicolon at the end of the func main() line |
Write func main() { on one line, or run gofmt -w file.go |
go: go.mod requires go >= 1.XX |
The project needs a newer Go than the APT version | Install a versioned package (Ubuntu 24.04) or the go.dev tarball |
sudo go ... says command not found but go works |
sudo uses its own secure PATH without /usr/local/go/bin |
Do not use sudo for go commands; build as your user |
| Strange errors right after an upgrade | A new tarball was extracted over the old /usr/local/go |
Delete /usr/local/go and extract the archive again |
This is the exact error we got on Ubuntu 24.04 when the brace was placed on its own line, as in the older version of this guide:
$ go run broken.go
# command-line-arguments
./broken.go:4:1: syntax error: unexpected semicolon or newline before {
Remove Go from Ubuntu
| Installed with | Remove with |
|---|---|
APT (golang-go) |
sudo apt remove golang-go && sudo apt autoremove |
| Versioned APT package | sudo apt remove golang-1.26-go, then delete its line from ~/.profile |
| Snap | sudo snap remove go |
| Tarball (wget or curl) | sudo rm -rf /usr/local/go, then delete the PATH lines from ~/.profile |
Removing Go does not delete ~/go, which holds downloaded modules and programs installed with go install. Delete it yourself only if you no longer need them. Afterwards, type -a go should print nothing.
Which method should you use?
On Ubuntu 26.04, the APT package already gives you Go 1.26, which is enough for most projects. On Ubuntu 24.04, the default Go 1.22 is old, so use golang-1.26-go if you want updates through APT, or the go.dev tarball if you always want the newest release. If you are still deciding whether to move the machine itself, see how to upgrade Ubuntu 24.04 to 26.04. For an editor with Go support, install Visual Studio Code on Ubuntu and add the Go extension; Go is also the language behind tools such as kubectl.
FAQ
Do I need to set GOROOT or GOPATH?
No. The go command works out GOROOT from its own location, and GOPATH defaults to ~/go. Run go env GOROOT GOPATH to see the values; with the APT package on Ubuntu 24.04 they were /usr/lib/go-1.22 and /root/go (for the root user) in our test.
Is golang-go the same as Go?
Yes. golang-go is Ubuntu’s package name for the Go toolchain. The program it installs is still called go.
Can I have two Go versions installed?
Yes. The APT, versioned, snap and tarball installs live in different folders. Whichever go comes first in PATH is the one that runs, which type -a go shows.