How to Install Go Language 1.20 in Ubuntu 20.04 | Ubuntu 22.04 | Debian 11

This simple tutorial shows how to install the latest version of Google’s Go programming language in Ubuntu and Debian.

The open source go language is available in the universe repository of Ubuntu and Debian. However, it’s old and will never receive updates. To get the latest version, here’s how to install it via the official tarball.

1. Remove old Golang package:

For those who have already installed the old version via the apt command, backup your projects and remove the old installation via the command below.

Open terminal either from start menu or by pressing Ctrl+Alt+T on keyboard. When it opens, run command to remove golang:

sudo apt remove --autoremove golang
Remove the old Golang package

2. Download the Latest Go Language Tarball:

Now download the Linux tarball from its official website:

Select download the “go1.20.linux-amd64.tar.gz” package for 64-bit modern PC/laptop, or:

  • go1.20.linux-386.tar.gz‘ for old 32-bit PC
  • go1.20.linux-arm64.tar.gz‘ for arm64 devices,e.g., Apple Silicon and Raspberry Pi.
  • or ‘go1.20.linux-armv6l.tar.gz‘ for armv6.

Don’t know the OS architecture? Try uname -m command in terminal.

3. Install Go Language:

After downloaded the source tarball, open terminal by searching from the overview screen (or start menu) and run the commands below one by one.

Then run the commands below one by one to remove old package if any, and extract the tarball to ‘/usr/local’ directory.

  • 1.) Firstly, run command to remove old installation if any:
    sudo rm -rf /usr/local/go
  • 2.) Next, install Go by extracting the tarball to “/usr/local” directory:
    sudo tar -C /usr/local -xzf ~/Downloads/go*.linux-amd64.tar.gz

Depends on the OS architecture, you may replace amd64 in the code with 386, arm64, or armv6l.

4. Set PATH Environment:

After step 3, you may start using Go by running command:

/usr/local/go/bin/go <command> [arguments]

Without typing the absolute path every time, you may add ‘/usr/local/go/bin’ to your PATH. To do so, just run the command below in terminal:

NOTE: check your path via $PATH command. And, skip the command below if '/usr/local/bin/go' is already in your path
sudo sh -c 'echo "export PATH=$PATH:/usr/local/go/bin" >> /etc/profile'

NOTE: the PATH will take effect after log out and back in. Or, run export PATH=$PATH:/usr/local/go/bin to make it work in current terminal window.

5. Verify:

To verify Go package version, run command in terminal:

go version

It should output something look like:

[email protected]:~$ go version
go version go1.20 linux/amd64

(Optional) Remove Go Language

As mentioned in Step 3, you may remove the Go language environment simply by running command in terminal:

sudo rm -rf /usr/local/go

That’s all. Enjoy!

Hi, I'm Merilyn Ne, a computer geek working on Ubuntu Linux for many years and would like to write useful tips for beginners. Forgive me for language mistakes. I'm not a native speaker of English.