Installtion and Configuration

Official binary distributions are available for the FreeBSD (release 10-STABLE and above), Linux, macOS (10.10 and above), and Windows operating systems and the 32-bit (386) and 64-bit (amd64) x86 processor architectures.

System requirements

Go binary distributions are available for these supported operating systems and architectures. Please ensure your system meets these requirements before proceeding. If your OS or architecture is not on the list, you may be able to install from source or use gccgo instead.

Download the archive and extract it into /usr/local, creating a Go tree in /usr/local/go. For example:

tar -C /usr/local -xzf go.x.tar.gz

snap installation Go

First install snap in to your ubuntu system.

sudo apt install snapd

Install Go

sudo snap install go --classic

Setup Go Environment

Add this to your ~/.bashrc file

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

export GOROOT=/usr/local/go

GOPATH is the location of your work directory. For example my project directory is ~/go, you can create what ever folder structure you want.

export GOPATH=$HOME/go

Sytem wide PATH setting

export PATH=$GOPATH/bin:$GOROOT/bin:$PATH

To check the go version installed in your system

go version

go version go1.13.5 linux/amd64

Get all go evironment variable settings.

go env

GOARCH=”amd64” GOBIN=”” GOCACHE=”/home/pradeek/.cache/go-build” GOENV=”/home/pradeek/.config/go/env” GOHOSTARCH=”amd64” GOHOSTOS=”linux” GOOS=”linux” GOPATH=”/home/pradeek/go” GOPROXY=”https://proxy.golang.org,direct” GOROOT=”/snap/go/4901” GOSUMDB=”sum.golang.org” GOTOOLDIR=”/snap/go/4901/pkg/tool/linux_amd64” GCCGO=”gccgo” AR=”ar” CC=”gcc” CXX=”g++ ….