How to install Go (compiler and tools) on Linux

If you want to compile a program which is written in Go, you need to start with the installation of the Go compiler.

Manual installation of the latest version of the Go compiler

If the repository of applications for your distribution does not have Go, or you want to manually install the latest version of the compiler, then follow this guide further.

The following manual have been successfully tested on Kali Linux, Arch Linux, BlackArch, Linux Mint, Ubuntu. It should also work on almost any Linux distribution.

Open the .bashrc file in the user directory with any text editor:

gedit ~/.bashrc

And to create new environment variables, add the following lines to this file:

export GOPATH=/home/git/go
export GOROOT=/usr/local/src/go
export PATH=${PATH}:$GOROOT/bin:/home/git/go/bin

When you are ready, save your changes and close the file.

These changes will take effect after the reboot. Instead of restarting the computer, run:

source ~/.bashrc

The following command automatically detects and downloads the latest version of the Go language files:

wget `curl -s | grep -E -o 'https://[a-z0-9./]{5,}go[0-9.]{3,}linux-amd64.tar.gz' | head -n 1`

Extract the downloaded archive:

tar zxf go*.linux-amd64.tar.gz

Move files to $GOROOT, which we specified in ~/.bashrc.

sudo mv go $GOROOT

Now type in the terminal:


Help should appear:

Installing Go from Standard System Repositories

Currently, the Go language compiler has been added to some popular distributions and can be easily installed from the standard repository. So start by checking if there is a golang or Go package in your repositories.

In Debian and its derivatives (for example, in Kali Linux), Go is installed with the following command:

sudo apt install golang

In Arch Linux and derivatives, Go is installed as follows:

sudo pacman -S go

Last Updated on

Recommended for you:

Leave a Reply

Your email address will not be published.