Go Lang is an open source programming language developed by a team of Google engineers in 2007. Go language was designed to resolve the common criticisms of other languages while maintaining their positive characteristics and most widely used for writing servers these days.

Extract the archive and move it to /usr/local. You can also place the Go lang binary to your custom location instead of /usr/local.

# tar -zxvf go1.9.2.linux-amd64.tar.gz -C /usr/local/

Setup Go Environment variables

Now you would need to setup two important variables for Go, GOROOT (PATH) and GOPATH. Add /usr/local/go/bin to your path variable. You can add this by running below command (temporary) or place the following command in /etc/profile or $HOME/.profile file for persistent across sessions.

export PATH=$PATH:/usr/local/go/bin

If you have installed Go on custom location replace /usr/local/go/bin/ with /path/to/bin/ directory.

GOPATH is a Go environment variable for your project workspace. Let’s create a workspace directory called “work” in your home directory.

mkdir $HOME/work

Set GOPATH variable. You can add this by running below command (temporary) or place the following command in /etc/profile or $HOME/.profile file for persistent across sessions.