TIP
This walkthrough uses macOS.
Using Homebrew on macOS makes switching between multiple Go versions straightforward.
Install the latest version:
shell
brew install goAt the time of writing, the latest Go release is 1.20:
shell
go version
go version go1.20.2 darwin/arm64Install a specific version:
shell
brew install go@1.19First, unlink the current version:
shell
brew unlink go
Unlinking /opt/homebrew/Cellar/go/1.20.2... 2 symlinks removed.Then link the version you want:
shell
brew link go@1.19
Linking /opt/homebrew/Cellar/go@1.19/1.19.7... 2 symlinks created.
If you need to have this software first in your PATH instead consider running:
echo 'export PATH="/opt/homebrew/opt/go@1.19/bin:$PATH"' >> ~/.zshrcTest that the switch succeeded:
shell
go version
go version go1.19.7 darwin/arm64INFO
Article republished from: How to Use Multiple Go Versions (Mac)
