Installation of latest Go language binaries on Ubuntu 16.04 Xenial Xerus Linux


Go is an open source programming language developed by Google. The objective is to install latest Go language pre-compiled binaries on Ubuntu 16.04 Linux.


Privileged access to your Ubuntu System as root or via sudo command is required.




  • # – requires given linux commands to be executed with root privileges either directly as a root user or by use of sudo command
  • $ – requires given linux commands to be executed as a regular non-privileged user


Download Go language binaries

First, we need to download Go language binaries. Visit page and either download your relevant Golang Linux libraries directly using your browser or simply use wget command as shown below:

$ wget -q

Once downloaded, you should be able to see the Go tarball with ls command:

$ ls go*

Install Go binaries

The installation of Go binaries simply involves a previously downloaded tarball decompression into a desired directory. The below command will extract the content of go1.7.4.linux-amd64.tar.gz tarball into /usr/local/bin/go directory.

$ sudo tar -C /usr/local/bin -xzf go1.7.4.linux-amd64.tar.gz

Check the content of /usr/local/bin directory:

$ ls /usr/local/bin/

Setup Go Environment

All Go binaries are now ready, what remains, is Go environment setup. To do so, open your favorite text editor and append the following lines into your ~/.bashrc file:

# golang local root installation directory
export GOROOT=/usr/local/bin/go
# golang binary-release PATH.
export PATH=${PATH}:${GOROOT}/bin

# golang binaries location
export GOPATH=$HOME/go
# golang compiled binaries PATH.
export PATH=${PATH}:${GOPATH}/bin

Now we need to source the above edited ~/.bashrc file which makes all new Go environment variables available. To do so, either re-login from your current shell session or execute:

$ . .bashrc

Testing Go Language Installation

All should now be ready. First, check go version:

$ go version
go version go1.7.4 linux/amd64

Execute a sample hello world example:

$ sudo apt-get install git
$ go get
$ hello 
Hello, Go examples!

Go Language hello world example ubuntu