The most recent version of Go is 1.17 (at the time of writing). If your system already comes with a version of Go, you may check your version like this:
go versionWe recommend installing the latest version of Go, but earlier versions may also work.
These instructions apply if you have a Linux distribution installed natively, in a virtual machine (VM) or in the Windows Subsystem for Linux (WSL).
It is advisable to use your distribution's package manager (e.g. apt for Ubuntu) to make it easier to maintain the installation.
We recommend adding the golang-backports repository to get the latest version of Go, as indicated here.
sudo add-apt-repository ppa:longsleep/golang-backports
sudo apt updateThen you can install the latest version of Go with the following command:
sudo apt install golang-goAlternatively you can install Go with sudo apt install golang, though you might get an older version if you are not running the latest Ubuntu release.
For other Linux distributions you can install Go with the distribution's package manager.
Alternatively you can download Go from the website and follow the instructions on the Go website to install it manually.
If you use the Homebrew package manager you can simply install Go with the following command:
brew install goAlternatively you can download Go from the website and follow the instructions on the Go website to install it manually.
We highly recommend either running Linux in a VM or WSL if you have a Windows system. Alternatively you can download Go from the website and follow the instructions on the Go website to install it manually.
You should add $GOPATH/bin to PATH so that binaries installed with go get can be used from the command line.
To achieve this you should add the following line to the end of the file $HOME/.profile.
PATH=$PATH:$(go env GOPATH)/binThis can be done with a text editor, e.g. vim or vscode, or simply by running this command:
echo 'PATH=$PATH:$(go env GOPATH)/bin' >> $HOME/.profileThe changes will take effect the next time you log in. To make the changes take effect at once you should run the following command:
source $HOME/.profile