Programming

How to Install Golang on Ubuntu 20.04

In this article, we’ll explain how to install Golang on Ubuntu 20.04.

Go’s simplicity and versatility has made it to be the preferred language for developing high-performance web applications and microservices.

Prerequisites

  • Ubuntu 20.04 Dedicated server or VPS
  • A root user access or normal user with administrator privileges.

Step 1. Keep you server up to date

# apt update -y

# apt upgrade -y

Step 2. Download and extract Go 1.15.4

We will download Go using wget command and extract it in /usr/local path.

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

# tar -zxvf go1.15.4.linux-amd64.tar.gz -C /usr/local

At the time of writing this guide, the latest available version was 1.15. You can check the latest Go version from the Go official download page.

Step 3. Setup Environment variables

The Go’s runtime and build executables are now available under /usr/local/go/bin. Add the executable path to PATH environment variable. Add the GOROOT environment variable referencing your local Go installation. Use thesource command to reload the updated values.

# echo 'export GOROOT=/usr/local/go' | sudo tee -a /etc/profile

# echo 'export PATH=$PATH:/usr/local/go/bin' | sudo tee -a /etc/profile

# source /etc/profile

Step 4. Verify the installation

To verify the installation, we can check the version of the Go by using following command:

# go version

Output will show similar like:

go version go1.15.4 linux/amd64

That’s it. The installation has been completed. Learn how to write a simple application in Go Language.

In this article, we have seen how to install Golang on Ubuntu 20.04. Learn how to write a simple application in Go language.

Related Articles