Install Golang on Linux – Step-By-Step Guide

Filed Under: UNIX/Linux
Install Golang On Linux Ubuntu Debian

In this tutorial, we go over the steps to install Golang on Linux. Go is a modern programming language created by Google. They create the language to fill in the gap of efficiently handling large databases. Existing programming languages were incapable of handling these volumes. It is a language renowned for its design, simplicity, and ability to tackle the development scaling issue.

Go is simplistic, powerful, and fast. This has made it a popular programming language in less than a decade since its release. First released in 2012, Go is used by major companies such as SoundCloud, Uber, Twitch among others, while being heavily used by Google as well.

Steps to Install Golang on Linux

Let’s get right into the steps that are required to have a fully functional Golang installation on our Linux system here.

1. Update System Repositories

Before we begin with the installation, we want to make sure that all our system repositories are up-to-date. To do this, we need to update our default repositories using the apt package management service

To do this, you need to open the terminal on your Ubuntu system and type the following. 

sudo apt update
sudo apt upgrade

2. Download the Go installation package

To install Go on your system, you need to visit Golang.org website and navigate to the download page. Here, check the latest available version (1.14.4 at the time of writing) and download it to your system. We can do so using the wget command.

wget https://dl.google.com/go/go<versionnumber>.linux-amd64.tar.gz
Wget Golang Install Golang On Linux Ubuntu
Wget Golang Installation Package

As you can see in the above screenshot, the downloaded file is available in your system.

3. Extract the Archive

Now, we will extract the archive in /usr/local to create a Go directory at /usr/local/go.

This can be using the following command.

sudo tar -C /usr/local -xzf go<versionnumber>.linux-amd64.tar.gz

Next, we need to add the /usr/local/go/bin to the PATH environment variable. Adding this to /etc/profile will cause a global installation while adding it to $HOME/.profile will install Go on the current user.

4. Setup Environment Variables for Golang

We use the following command to set the variable.

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

Now, we will apply the changes to our current session. We can do this with the following command: 

sudo source $HOME/.profile

5. Verifying the installation

Once we install Go on Linux, we need to verify the installation before we can start using Go on our system. We can verify this by asking the terminal for the version of the Go programming language on our system. To do so, we enter this in our terminal.

go version
Go Version
Go Version

This will fetch the version of the Go programming language on our system. At the time of making this tutorial, the latest available stable release of Go is version 1.14.4 as seen in the screenshot below.

Conclusion

Go is easy to learn and provides an elegant yet powerful option for developers. Further, it is one of the fastest-growing programming languages today. Go is widely used in the fields of system programming, serverless computing, IoT, and cloud-native development.

We hope this tutorial was able to help you install Go on Linux. If you have any feedback, queries, or suggestions, feel free to reach out to us in the comments below.

Leave a Reply

Your email address will not be published. Required fields are marked *

close
Generic selectors
Exact matches only
Search in title
Search in content
Search in posts
Search in pages