Skip to content

Instantly share code, notes, and snippets.

@tsaarni
Last active December 28, 2019 09:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tsaarni/5841c364fbe31532ee2c644452e628cf to your computer and use it in GitHub Desktop.
Save tsaarni/5841c364fbe31532ee2c644452e628cf to your computer and use it in GitHub Desktop.
Install any version of go (using existing installation of go)

Install any version of go

Get a list of all available go versions by running:

curl -s "https://golang.org/dl/?mode=json&include=all" | jq -r '.[].version' | sort -V

To install latest version of go (not including beta versions) by using existing go installation for bootstrapping:

GOLATEST=$(curl -s "https://golang.org/dl/?mode=json&include=all" | jq -r '.[].version | select(contains("beta") | not )' | sort -V | tail -1)
go get golang.org/dl/$GOLATEST   # compiles go downloader
$GOLATEST download               # downloads go release to ~/sdk/ and installs to $GOPATH/bin/
$GOLATEST version                # check that it worked

Set the new version as default

ln -sf $GOPATH/bin/$GOLATEST $GOPATH/bin/go
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment