Upgrade or Downgrade Go installed with Homebrew.
How to upgrade or downgrade Go installed with Homebrew.
While working in cross team environment, I just had the issue that I installed Go 1.14 which messed up my VSCode auto completion and it is also not supported by the CI/CD pipeline I was using. This meant I needed to downgrade to lower Go versions either 1.12/1.13.
This took me a more longer than I’d be willing to expected a fix. Partially because the naming in Homebrew is sometimes a bit hard to follow #11091 .
Here are 3 simple steps involved:
- Install wanted version,
- unlink old one,
- link new one.
Check current version
~ go version go version go1.14.13 darwin/amd64
Install specific go version you want
The available versions are listed in the Hombrew directory. The Example for Go would be here .
~ brew install firstname.lastname@example.org Updating Homebrew... ==> Auto-updated Homebrew! Updated 2 taps (homebrew/core and homebrew/cask). ==> Updated Formulae email@example.com ✔ ==> Downloading https://firstname.lastname@example.org Already downloaded: /Users/username/Library/Caches/Homebrewemail@example.com ==> Pouring firstname.lastname@example.org ==> Caveats email@example.com is keg-only, which means it was not symlinked into /usr/local, because this is an alternate version of another formula. If you need to have firstname.lastname@example.org first in your PATH run: echo 'export PATH="/email@example.com/bin:$PATH"' >> ~/.zshrc ==> Summary 🍺 /usr/local/Cellarfirstname.lastname@example.org/1.12.9: 9,819 files, 452.8MB
Unlink currently installed go version
~ brew unlink go Unlinking /usr/local/Cellar/go/1.14... 3 symlinks removed
Force link the specific go version
As the specific formula we want (email@example.com) is a keg-only formula it must be linked with --force. If you try without it’ll tell you just that. As explained in the FAQ a key-only formula is one that’s only installed into our /usr/local/Cellar directory without being linked automatically.
~ brew link --force firstname.lastname@example.org Linking /usr/local/Cellaremail@example.com/1.12.9... 3 symlinks created
If you need to have this software first in your PATH instead consider running: echo 'export PATH="/firstname.lastname@example.org/bin:$PATH"' >> ~/.zshrc
Now that everything is linked correctly it should show the specific version we want:
~ go version go version go1.12.9 darwin/amd64