Skip to content

Instantly share code, notes, and snippets.

@momota
Created November 6, 2018 08:03
Show Gist options
  • Save momota/2d7ddb594193789ad5d6c1c5ad861df8 to your computer and use it in GitHub Desktop.
Save momota/2d7ddb594193789ad5d6c1c5ad861df8 to your computer and use it in GitHub Desktop.
Install golang (version 1.11.2) on Ubuntu 18.04.1

Environment

$ cat /etc/lsb-release 
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=18.04
DISTRIB_CODENAME=bionic
DISTRIB_DESCRIPTION="Ubuntu 18.04.1 LTS"


$ go version

Command 'go' not found, but can be installed with:

sudo snap install go         # version 1.11.2, or
sudo apt  install golang-go
sudo apt  install gccgo-go 

See 'snap info go' for additional versions.

Installation latest golang (1.11.2)

Obey Ubuntu · golang/go Wiki.

$ sudo snap install --classic go
go 1.11.2 from Michael Hudson-Doyle (mwhudson) installed

$ go version
go version go1.11.2 linux/amd64

You can not install latest version of golang via apt.

$ sudo apt-get update
$ sudo apt-cache search golang | grep 1.1
golang-1.10 - Go programming language compiler - metapackage
golang-1.10-doc - Go programming language - documentation
golang-1.10-go - Go programming language compiler, linker, compiled stdlib
golang-1.10-race-detector-runtime - Runtime support for Go's race detector
golang-1.10-src - Go programming language - source files
golang-github-twinj-uuid-dev - RFC 4122 and DCE 1.1 compliant UUIDs in Go

# => We can not find golang-1.11*

Setting GOPATH

Just add the following lines to ~/.bashrc (or ~/.zshrc, ~/.config/fish/config.fish and so on) and this will persist.

export GOPATH=$HOME/go
export PATH=$PATH:$GOROOT/bin:$GOPATH/bin
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment