The Hidden Blog

As it turns out, I do have a hostname.

Downgrade Go installed with Homebrew

Published on Sep 13, 2019

I just had the issue that I installed Go 1.13 which messed up VSCode auto completion and is also not supported by the CI pipeline I wanted to use. This meant I needed to downgrade to Go 1.12.9.

This took me a bit longer than I'd be willing to admit. Partially because the naming in Homebrew is sometimes a bit hard to follow #11091.

There are 3 simple steps involved: Install wanted version, unlink old one, link new one.

Check current version

~|⇒ go version
go version go1.13 darwin/amd64

Install specific version you want

The available versions are listed in the Hombrew directory. The Example for Go would be here.

~|⇒ brew install go@1.12
Updating Homebrew...
==> Auto-updated Homebrew!
Updated 2 taps (homebrew/core and homebrew/cask).
==> Updated Formulae
openssl@1.1 ✔
==> Downloading https://homebrew.bintray.com/bottles/go@1.12-1.12.9.mojave.bottle.tar.gz
Already downloaded: /Users/username/Library/Caches/Homebrew/downloads/6392e5d3faa67a6132d43699cf470ecc764ba42f38cce8cdccb785c587b8bda8--go@1.12-1.12.9.mojave.bottle.tar.gz
==> Pouring go@1.12-1.12.9.mojave.bottle.tar.gz
==> Caveats
go@1.12 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 go@1.12 first in your PATH run:
  echo 'export PATH="/usr/local/opt/go@1.12/bin:$PATH"' >> ~/.zshrc

==> Summary
🍺  /usr/local/Cellar/go@1.12/1.12.9: 9,819 files, 452.8MB

Unlink currently installed version

~|⇒ brew unlink go
Unlinking /usr/local/Cellar/go/1.13... 3 symlinks removed

Force link the specific version

As the specific formula we want (go@1.12) 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 go@1.12
Linking /usr/local/Cellar/go@1.12/1.12.9... 3 symlinks created

If you need to have this software first in your PATH instead consider running:
  echo 'export PATH="/usr/local/opt/go@1.12/bin:$PATH"' >> ~/.zshrc

Check version

Now that everything is linked correctly it should show the specific version we want:

~|⇒ go version
go version go1.12.9 darwin/amd64

I hope this was helpful, if you like posts like this follow me on Twitter: @tehwey