How to Install Go Language 1.17 in Ubuntu 20.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. Besides using the upcoming Ubuntu 21.10 that include Golang 1.17, here’s how to install the latest version step by step.

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:

For modern 64-bit computer and laptop, select download the “go1.x.x.linux-amd64.tar.gz” package. Or grab the “386” package for old 32-bit PC, or “arm64” for Apple Silicon and Raspberry Pi devices.

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.

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.

3.) Finally set PATH environment variable by running the command in terminal:

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.

Set the PATH, will work in next logon

(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!

Merilyn Ne
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.