Installing Go on Ubuntu 16.04

/ / installing go on ubuntu 16.04

Updated: 2017-10-02

How to install Go

There are several ways to install Go on Ubuntu. Before you get tempted to install using sudo apt then you should realize that you most likely won’t be using the latest stable version, and when it comes to Go then there’s really no reason not to use the latest stable version.

I therefore recommend you download the archive from here, and run the following command:

tar -C /usr/local -xzf go$VERSION.$OS-$ARCH.tar.gz

Remember to replace the VERSION, OS and ARCH variables, e.g. if you were installing version 1.9.1 on Ubuntu 64 bit, then you’d run the command: tar -C /usr/local -xzf go1.9.1.linux-amd64.tar.gz.

After installing golang, remember to create your GOPATH. This can be done by adding the following to your ~/.bashrc file:

export GOPATH=$HOME/go
export GOBIN=$HOME/go/bin
export PATH=$PATH:$GOPATH/bin