How to Install Go in Ubuntu 16.04

Download the latest version of Go. Ubuntu does come with a version of go in it’s apt listings but it won’t be as up-to-date as downloading it directly. Once downloaded we extract it into a folder we can work with.

wget https://storage.googleapis.com/golang/go1.8.1.linux-amd64.tar.gz
tar xvf go1.8.1.linux-amd64.tar.gz

Once downloaded and extracted, move to the folder to /usr/local so we have it globally.

sudo chown -R root:root ./go
sudo mv go /usr/local

We then need to add some bash variables so Go knows where our directory is located. GOPATH should point to the folder where you’ll be working in.

vim ~/.profile
export GOPATH=$HOME/work
export PATH=$PATH:/usr/local/go/bin:$GOPATH/bin
source ~/.profile

Leave a Reply

Your email address will not be published. Required fields are marked *