Install Go 1.11 on Ubuntu 18.04 & 16.04 LTS

Go 1.11 has hit the ground on 24 August 2018 and it has introduced few really needed tools and components including versioned modules, Experimental WebAssembly support, Debugging improvements and minor changes to core packages and performance/run-time.

This tutorial will help you to install Go 1.11 on your Ubuntu 18.04 LTS, 16.04 LTS, and 14.04 LTS systems.

Step 1 — Install Go Language

Upgrade to apply latest security updates on Ubuntu.

sudo apt-get update
sudo apt-get -y upgrade

Now you need to download the Go binary file. You can find the list of download links as per OS and architecture from their official package. To install it on Ubuntu 64-bit OS hit following commands

cd /tmp
wget https://dl.google.com/go/go1.11.linux-amd64.tar.gz

Now extract the downloaded archive and install it to the desired location on the system. I generally keep it under /usr/local directory as suggested by standards.

sudo tar -xvf go1.11.linux-amd64.tar.gz
sudo mv go /usr/local

Step 2 — Setup Go Environment

Now let’s setup Go language environment variables GOROOT , GOPATH and PATH.

GOROOT is the location where Go package is installed on your system.

GOPATH is the location of your work directory. For example here directory is ~/go .

Open your `.profile`file and add global variable as follow at the end of the file. You may want to add this into .zshrc or.bashrc file as per your shell configuration.

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

Step 3 — Update current shell session

source ~/.profile

This will allow you to use go commands without restarting your terminal.

Step 4 — Verify Installation
You have successfully installed and configured go language on your system.

To check Go version.

go version
// go version go1.11 linux/amd64

Now also verify all configured environment variables using the following command.

go env
GOARCH=”amd64"
GOBIN=””
GOCACHE=”/home/ridham/.cache/go-build”
GOEXE=””
GOFLAGS=””
GOHOSTARCH=”amd64"
GOHOSTOS=”linux”
GOOS=”linux”
GOPATH=”/home/ridham/go”
GOPROXY=””
GORACE=””
GOROOT=”/usr/local/go”
GOTMPDIR=””
GOTOOLDIR=”/usr/local/go/pkg/tool/linux_amd64"
GCCGO=”gccgo”
CC=”gcc”
CXX=”g++”
CGO_ENABLED=”1"
GOMOD=””
CGO_CFLAGS=”-g -O2"
CGO_CPPFLAGS=””
CGO_CXXFLAGS=”-g -O2"
CGO_FFLAGS=”-g -O2"
CGO_LDFLAGS=”-g -O2"
PKG_CONFIG=”pkg-config”
GOGCCFLAGS=”-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build476037005=/tmp/go-build -gno-record-gcc-switches”

You have successfully installed Go 1.11. You can now make some cool stuff with Go.

If you enjoyed this article, spare me some claps — it means the world to the writer and follow me if you want to read more articles about Go, JS, Technology and Startups.