Go Version Management

Too long did not read: go get golang/dl/go1.x.z; go1.x.z download


Installing Go via homebrew or golang.org will pull the latest version of Go (1.15 at the time of writing). However, in some cases (such as writing a blog post or book) you may need to pin or install a specific version.

The Go community has created a few Go version management programs such as: gvm and g . If you do not want to install these version managersyou can also optionally install various versions of Go via golang.org (at the time of this writing).

# Fetch the package from golang.org
# NOTE: this will download source for various past versions of go
# x and z are the version number respectively
$ go get golang.org/dl/go1.x.z

Once you have fetched the repository you can see the various versions available in your $GOPATH

$ ls $GOPATH/src/golang.org/dl

AUTHORS         go1.11.9        go1.13.15       go1.15.6
CONTRIBUTING.md go1.11beta1     go1.13.2        go1.15beta1
CONTRIBUTORS    go1.11beta2     go1.13.3        go1.15rc1
LICENSE         go1.11beta3     go1.13.4        go1.15rc2
PATENTS         go1.11rc1       go1.13.5        go1.5.4
README.md       go1.11rc2       go1.13.6        go1.6.4
codereview.cfg  go1.12          go1.13.7        go1.7.6
go.mod          go1.12.1        go1.13.8        go1.8
go1.10          go1.12.10       go1.13.9        go1.8.1
go1.10.1        go1.12.11       go1.13beta1     go1.8.2
go1.10.2        go1.12.12       go1.13rc1       go1.8.3
go1.10.3        go1.12.13       go1.13rc2       go1.8.4
go1.10.4        go1.12.14       go1.14          go1.8.5
go1.10.5        go1.12.15       go1.14.1        go1.8.6
go1.10.6        go1.12.16       go1.14.10       go1.8.7
go1.10.7        go1.12.17       go1.14.11       go1.8beta1
go1.10.8        go1.12.2        go1.14.12       go1.8beta2
go1.10beta1     go1.12.3        go1.14.13       go1.8rc1
go1.10beta2     go1.12.4        go1.14.2        go1.8rc2
go1.10rc1       go1.12.5        go1.14.3        go1.8rc3
go1.10rc2       go1.12.6        go1.14.4        go1.9
go1.11          go1.12.7        go1.14.5        go1.9.1
go1.11.1        go1.12.8        go1.14.6        go1.9.2
go1.11.10       go1.12.9        go1.14.7        go1.9.3
go1.11.11       go1.12beta1     go1.14.8        go1.9.4
go1.11.12       go1.12beta2     go1.14.9        go1.9.5
go1.11.13       go1.12rc1       go1.14beta1     go1.9.6
go1.11.2        go1.13          go1.14rc1       go1.9.7
go1.11.3        go1.13.1        go1.15          go1.9beta1
go1.11.4        go1.13.10       go1.15.1        go1.9beta2
go1.11.5        go1.13.11       go1.15.2        go1.9rc1
go1.11.6        go1.13.12       go1.15.3        go1.9rc2
go1.11.7        go1.13.13       go1.15.4        gotip
go1.11.8        go1.13.14       go1.15.5        internal

To install and use the past version of Go run:

 # Installs to $GOPATH/bin/go1.x.z
 
 $ go1.x.z download
 
 $ ls $GOPATH/bin
 
go1.14             ...              ...
...                ...              ...

You can now run the past version of Go:

$ go1.14 version

go version go1.14 darwin/amd64

Have fun!