Golang is an open source programming language developed by a team at Goole. Recently Google has released latest version 1.10.3. This short tutorial will guide you how to manually install Go version 1.10.3 on your machine. We assume you run Ubuntu 16.04 LTS operating system.
Step 1 – Update Your Ubuntu System
Login to your machine running Ubuntu system, update and upgrade to apply latest updates.
$ sudo apt-get update $ sudo apt-get upgrade
Now we are ready to download the Go binary (tar archive).
Step 2 – Download the Go Binary
To download different version go to official Google download page. Let’s download latest version – 1.10.3:
$ wget https://dl.google.com/go/go1.10.3.linux-amd64.tar.gz
Extract downloaded tar archive and install it to the directory of your choice. We will install the binary to /usr/local dir.
Step 3 – Install Go Language
Delete old installation of the Go language
$ sudo rm -rf /usr/local/go
Untar and move the go dir to /usr/local/
$ sudo tar -xvf go1.10.3.linux-amd64.tar.gz $ sudo mv go /usr/local
Step 4 – Setup Golang Environment
Once we have Go installed we need to setup Go environment variables. As a minimum we need GOROOT, GOPATH and PATH.
$GOROOT is the location where Go is installed on the system.
$ export GOROOT=/usr/local/go
$GOPATH is the location of the work directory on the system. Go will setup the working directory to $HOME/go as a default location.
$ export GOPATH=$HOME/workgo
Now we need to setup the $PATH var to be able to access Go binary from any place in the system.
$ export PATH=$GOPATH/bin:$GOROOT/bin:$PATH
All three variables are set for the current session only. To make them permanent add above commands to ~/.profile or ~/.bash_profile file.
Step 5 – Verify Installation
The last step is to verify if Go is successfully installed and configured on your system.
$ go version go version go1.10.3 linux/amd64
As the last step we need to verify if all configured environment variables are set.
$ go env
In the next post we will automate the installation with Ansible.