GoLang: Installing the Go Programming language on Ubuntu 14.04

The Go programming language has gotten considerable momentum, and the fact that it compiles down to machine code has made it popular in containers like Docker where a single executable binary fits the execution model perfectly.

This article will detail installation on Ubuntu 14.04 with the standard hello world validation.


First, download the latest 64 bit linux package from the download page.  Unzip to the standard location, and run a quick check of the version.

$ cd /tmp

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

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

$ /usr/local/go/bin/go version
go version go1.8.1 linux/amd64


Before going further, make sure to set the GOPATH and PATH variables to your environment.

On Ubuntu, append the following to ~/.profile:

export GOPATH=$HOME/work
export GOBIN=$GOPATH/bin
export PATH=$PATH:/usr/local/go/bin

Then create the subdirectories and source the profile so that your current environment is updated.  Now you should be able to run go without needing to specify the path.

$ source ~/.profile
$ mkdir -p $GOPATH
$ mkdir -p $GOBIN
$ go version
go version go1.8.1 linux/amd64

Hello World

Let’s start by going into the $GOPATH, and creating a source file.

$ mkdir -p $GOPATH/src/hello
$ cd $GOPATH/src/hello

Create a file named $GOPATH/src/hello/hello.go

package main

import "fmt"

func main() {
    fmt.Printf("hello, world\n")

And then compile and run:

$ go build
$ ./build
hello, world







On Windows, installer creates GOHOME and appends PATH



User should set new system var GOPATH=%userprofile%\go