Install Go (Golang) from source

Page content

Environment

I wrote this article while installing go on WSL.

Install Go lang

$ curl https://dl.google.com/go/go1.15.5.linux-amd64.tar.gz -o golang.tar.gz
$ sudo tar -C /usr/local -xzf golang.tar.gz
$ vim ~/.bashrc
## Add /usr/local/go/bin/ to path
## export PATH=/usr/local/go/bin:$PATH
$ source ~/.bashrc

## Check
$ go version
go version go1.15.5 linux/amd64

Upgrade the version

Just delete the current version like rm -rf /usr/local/go, and replace it with new version.

Tips: Installing Hugo on this setup (on WSL)

GCC and G++ are required (sudo apt install gcc g++).

$ cd /usr/local/go/src
$ sudo git clone https://github.com/gohugoio/hugo.git
$ cd hugo
$ sudo env "PATH=$PATH" go install --tags extended

## Check
$ hugo version
Hugo Static Site Generator v0.79.0-DEV/extended linux/amd64 BuildDate: unknown