Installing Go on Ubuntu

Installing Go on Ubuntu

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.

GOROOTis 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


要查看或添加评论,请登录

Rakesh Mothukuri的更多文章

  • Building an RSocket based Springboot application

    Building an RSocket based Springboot application

    Introduction RSocket translates to Reactive socket is a messaging protocol that works over TCP or Websockets…

  • The Command Pattern in?Java

    The Command Pattern in?Java

    Introduction You most likely have known about behavioural patterns by now. behavioral patterns are concerns about the…

  • An efficient way to compare strings in Go

    An efficient way to compare strings in Go

    Introduction One of the most overlooked operations is comparing two strings and this might not cause system overhead…

  • 8 Most used functions of strings package in Go

    8 Most used functions of strings package in Go

    Introduction The standard Go library strings package provides many string related functions. This blog lists…

  • Multiple Return Values: Golang

    Multiple Return Values: Golang

    In Golang, It is allowed to return multiple values from a function, using a return statement. The type of the return…

    2 条评论
  • go build vs go run

    go build vs go run

    Example : https://gist.github.

  • Superfast subatomic java (Quarkus) — a HelloWorld app

    Superfast subatomic java (Quarkus) — a HelloWorld app

    As part of my quest to get my idea into the cloud as an app, I stumbled across this beautiful product called QUARKUS…

  • WSL Ubuntu upgrade to Disco Dingo 19.04

    WSL Ubuntu upgrade to Disco Dingo 19.04

    After installing Ubuntu Microsoft app by default Ubuntu will install the latest stable Ubuntu LTS release. but if you…

社区洞察

其他会员也浏览了