How to Install Go on Ubuntu 20.04

Install Go on Ubuntu 20.04

In this article, we will have explained the necessary steps to install and configure Go on Ubuntu 20.04 LTS. Before continuing with this tutorial, make sure you are logged in as a user with sudo privileges. All the commands in this tutorial should be run as a non-root user.

Go Lang (Golang) is an open-source programming language developed by a team of Google engineers in 2007. Go language was designed to resolve the common criticisms of other languages while maintaining their positive characteristics and most widely used for writing servers these days.

Install Go on Ubuntu 20.04 Linux

Step 1. First, before you start installing any package on your Ubuntu server, we always recommend making sure that all system packages are updated.

sudo apt update
sudo apt upgrade

Step 2. Installing Go on Ubuntu system.

  • Install Go from the Ubuntu default repository:
sudo apt install golang

Confirm the installation by checking for the go version:

go version
  • Install Go from source:

Download the Go binary from the official Go downloads page  using the wget command:

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

After that run the commands below to extract the tarball file into the /usr/local directory:

sudo tar -C /usr/local -xzf go1.15.5.linux-amd64.tar.gz

Step 3. Set Go Path.

Next, edit the $PATH environment variable so that the system knows where the Go executable binaries are located. You can do this either by appending the following line to the /etc/profile file (for a system-wide installation) or to the $HOME/.profile file:

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

Save the file, and apply the new PATH environment variable to the current shell session by typing:

source ~/.profile

Verify the installation by printing the Go version:

$ go version
go version go1.15 linux/amd64

Step 4. Build a Program in Go.

To learn how to create your first Go program, please visit the like below:

https://golang.org/doc/code.html

That’s all you need to do to install the Go (Golang) on Ubuntu 20.04 LTS Focal Fossa. I hope you find this quick tip helpful. For further reading on Go, please refer to their official knowledge base. If you have questions or suggestions, feel free to leave a comment below.