Installing Go on Linux

Gopher

Here, you’ll find the instructions to install Go on a Linux computer.

Extract the archive you downloaded into /usr/local, creating a Go tree in /usr/local/go.

For example, you can run the following command to do create the Go tree:

rm -rf /usr/local/go \
&& tar -C /usr/local -xzf go$version.$distro.tar.gz

After creating the directory tree, add /usr/local/go/bin to your PATH environment variable:

vim $HOME/.profile
# or /etc/profile (for a system-wide installation).

# add the following line to the end of your $HOME/.profile file.
# If you don't have such a file, create one.
export PATH=$PATH:/usr/local/go/bin

Note that changes made to a profile may not apply until you log out and log back into your machine. The apply the changes immediately, you can source your profile file as follows:

source $HOME/.profile

Finally, verify that you’ve installed Go by opening a terminal session and typing the following:

go version

After pressing the Enter key, if you see the installed version of Go, then you’re off to the races.

You Are All Set

That’s it. You are now ready to use Go in your system.