How to Install Go on Linux

Hey! If you love Go and building Go apps as much as I do, let's connect on Twitter or LinkedIn. I talk about this stuff all the time!

Want to learn how to build better Go applications faster and easier? You can.

Check out my course on the Go Standard Library. You can check it out now for free.


With over 10 years of development, Go is a popular language for building scalable and efficient software. In this article, we will guide you through the process of installing Go on Linux, including downloading, setting up the environment, and testing your installation.



Step 1: Download the Go Binary Package

The first step in installing Go is to download the binary package from the official website. You can find the latest version of Go on the official website, https://golang.org/dl.

Once you have downloaded the package, extract it to a directory of your choice using the following command:

tar -xvf go1.17.linux-amd64.tar.gz

This will extract the Go binary files to the current directory.

Step 2: Set up the Go Environment

Before you can start using Go, you need to set up the environment variables. The following steps show how to do this on Linux:

  1. Open your ~/.profile file in a text editor and add the following lines at the end of the file:
export GOROOT=$HOME/go
export GOPATH=$HOME/go
export PATH=$PATH:$GOROOT/bin

Replace $HOME/go with the directory where you have extracted the Go binary files.
2. Save and close the file.
3. Run the following command to update your environment variables:

source ~/.profile

Step 3: Test Your Installation

After setting up the environment, test your installation by running the following command in a terminal window:

go version

This should display the Go version number and other details about your installation. If you see an error message, make sure that the environment variables are set correctly.

Congratulations! You have successfully installed Go on Linux. You can now start writing Go code and using all the features of this powerful language.



Stay up to date on the latest in Coding for AI and Data Science

Intuit Mailchimp