Installing Go on Ubuntu

| Reading Time : 2 minutes | #backenddevelopment #Go


This blog will walk through installing Go 1.14.1 on Ubuntu 18.04.4 LTS

1.Install ubuntu updates

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

2.Download Go binary

Next logical step is to download the Go binary file, Latest software will be available at https://golang.org/dl/ and to install the version of ubuntu run below commands in terminal

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

Extract the downloaded tar and installing into the desired location in system. But generally following the documentation its best to install it under /user/local/go . Run below commands in terminal for installation

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

3.Environment setup

Three Go language environment variables we are setting are GOROOT , GOPATH and PATH.

GOROOT is the path where Go installed in the machine

GOPATH the location of the working directory.

In .profile file add above said global variables at the end of the file. You may want to add this into a .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

4.Renewing the shell sessions

source ~/.profile

5.Final check

Go should have been now installed successfully on the machine and to check if it is run below command

go version

and if its installed and configured well you should see below output on the terminal

GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/xxx/.cache/go-build"
GOENV="/home/xxx/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/rockey/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/xxx/snap/exercism/current/exercism/go/two-fer/go.mod"
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-build151852922=/tmp/go-build -gno-record-gcc-switches"

Resources for further reading :

  1. https://golang.org/ (official docs)
  2. https://go.dev/ ( developer portal)
  3. https://changelog.com/gotime (Go Time podcast) run by amazing people

If you find anything wrong or outdated i’d really appreciate if you could drop me a note on my social media or email( rockey5520@gmail.com) would be amazing.


Articles from blogs I follow around the net

powerctl: A small case study in Hare for systems programming

powerctl is a little weekend project I put together to provide a simple tool for managing power states on Linux. I had previously put my laptop into suspend with a basic “echo mem | doas tee /sys/power/state”, but this leaves a lot to be desired. I have to u…

via Drew DeVault's blog August 28, 2022

United States v. Microsoft Corp exhibits

Links to exhibits from the Microsoft anti-trust case, with a bit of info on each link. Projection of PC marketshare Share of new browser users Share of the browser market, grouped by major ISP, 3 month moving average Share of the browser market, grouped by ma…

via danluu.com August 24, 2022

Status update, August 2022

Hi all! This month I’ve been pondering offline-first apps. The online aspect of modern apps is an important feature for many use-cases: it enables collaboration between multiple people and seamless transition between devices (e.g. I often switch between my pe…

via emersion August 14, 2022

Generated by openring

© Copyright 2021-2022. Rakesh Mothukuri