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