Robert's Homepage

How to Manage Multiple Go Versions

#golang #how-to

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

Installing Go via homebrew or 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 . If you do not want to install these version managersyou can also optionally install various versions of Go via (at the time of this writing). Once you have fetched the repository you can see the various versions available in your $GOPATH

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!