Install Go in Ubuntu 22.04

Go is an open-source programming language. It was created at Google. In this article, we would discuss how to install Go in Ubuntu 22.04 release.

At the time of writing, v1.17.8 is its latest stable release. But, as of now, v1.17.3 is available through standard Ubuntu repository.

Two methods we will discuss to install Go in Ubuntu –

  1. through apt and,
  2. binary release (.tar.gz).

Note: Following operations would require you to have superuser privileges. In case you don’t have one then, we advise you to contact your System Administrator for assistance.

Method I. Install Go in Ubuntu 22.04 through apt

Since, the package is available through standard Ubuntu repository. Therefore, we need to update the repository first. This ensures we get to have the latest version of package available. Hence, open a terminal and issue the following –

sudo apt update

Next, to install Go –

sudo apt install golang-go

To verify for the Go version installed –

go version

It would return with the following output –

go version go1.17.3 linux/amd64
Method II. Install Go in Ubuntu 22.04 through binary release

We can also install Go through binary release available on official website of Go. Just Google search “Go” and first link on search page is our destination. On the homepage, click on Download link. On Downloads page, click on Archive file for Linux. For us the package was – go1.17.8.linux-amd64.tar.gz

Use tar command-line utility to extract the package – go1.17.8.linux-amd64.tar.gz

It would create go/ in the current directory.

Now, use a text-editor like nano to edit ~/.bashrc

nano ~/.bashrc

And, append the file with following entries –

export PATH="/path/to/directory/go/bin/:$PATH"

where, replace /path/to/directory/ with relevant PATH to directory Go.

To verify the installation –

go version

It would return with the following output –

go version go1.17.8 linux/amd64