How to Install Golang in Ubuntu


Go, sometimes known as “Golang,” is considered the most widely used programming language. The first version of Go, version 1.0, was released in November 2012, and it was created by Google. It enables you to design applications that are more attractive and reliable. The programming language Go is compiled. You must first construct a source code to create an executable file that will aid in the software’s execution. Go programming is used to create many popular platforms, including Docker, Kubernetes, Terraform, and Prometheus. It is a cross-platform, open-source programming language that may be used on Windows, Mac OS X, and Linux. In this article, we’ll discuss how we can install the GO programming language on Ubuntu 20.04.

Install Golang on Ubuntu 20.04

Go can be installed on the Ubuntu 20.04 system by different installation techniques. Here, we’ll look at two possible approaches to installing the Go language:

  • Installation of Golang using Ubuntu apt repository
  • Installation of Golang by downloading the source code

Method 1: Installation of Golang using Ubuntu apt repository

The official Ubuntu apt repository occasionally contains out-of-date Golang applications. The apt package manager, on the other hand, makes it simple to install Golang packages. Access the terminal window by pressing ‘Ctrl+Alt+t’. To install Go on an Ubuntu 20.04 system, update the packages list and enter the following command:

$ sudo apt upgrade && sudo apt update

Text Description automatically generated

Then, execute the following command to install Golang in Ubuntu:

$ sudo apt install golang

Text Description automatically generated

When it prompts for confirmation of the installation of Go packages, enter the ‘y’ key and the ‘Enter’ key. All essential Go dependencies will be installed on your machine after confirmation. You can easily verify the installation of Go by using the following command in the terminal to see the installed Go version:

$ go version

Text Description automatically generated

It can be seen from the above output that this machine has the default Go version 1.13.8 installed.

Method-2: Installation of Golang by downloading the source code

The most recent version of the Go programming language is required by the majority of software applications. In this case, you’ll be required to update your Ubuntu system to the latest Go version. At the time of writing, Go 1.17.1 was the most recent stable version available for installation. Check the latest version of Go on the official Go downloads page before downloading the binary archive. To install Go using the source code method; you can follow the following steps which are mentioned below:

Step 1: Save the Go binary archive

To locate and download the most recent stable version of Go, use the wget command on an Ubuntu 20.04 machine:

$ wget https://golang.org/dl/go1.17.1.linux-amd64.tar.gz

After you run the preceding command, a compressed tar file will be downloaded to your computer.

Text, timeline Description automatically generated

Step 2: Extract the binary archive

Run the following command to extract the tar into the /usr/local directory once the Go binary archive has been downloaded:

$ tar -xzf go1.17.1.linux-amd64.tar.gz -C /usr/local/

Step 3: Change the GO route variable

To tell the system where to seek Go executable binaries, we’ll add the Go directory path to the environment variable. The path to the Go directory can be added to either the /etc/profile file for a system-wide installation (which we will do here) or the $Home/.profile file for a specific user installation (which we will do here). Open the file ‘/etc/profile’ in a source code editor as follows:

$ sudo nano /etc/profile

Add the following path after pressing enter at the end of the file.

$ export PATH=$PATH:/usr/local/go/bin

Text Description automatically generated

You can press ‘Ctrl+O’ to save your changes, and then press ‘Ctrl+X’ to leave this file.

Activate the PATH environment variable by running the command (/etc/profile/source)

Finally, use the terminal command to verify the Go language version that is installed:

$ go version

Text Description automatically generated

Remove and uninstall Go

Remove the file where the binary archive is extracted as follows if you do not wish to use Go any longer on your system:

$ sudo rm –rf /usr/local/go

Text Description automatically generated


In this article, we’ve discussed how to install Go or Golang on an Ubuntu 20.04 system using various installation techniques. We’ve also gone through how to develop and run the GO application on your PC after it’s been installed.

Similar Posts