Skip to content

Instantly share code, notes, and snippets.

@BigOokie
Last active May 3, 2024 22:13
Show Gist options
  • Star 42 You must be signed in to star a gist
  • Fork 8 You must be signed in to fork a gist
  • Save BigOokie/d5817e88f01e0d452ed585a1590f5aeb to your computer and use it in GitHub Desktop.
Save BigOokie/d5817e88f01e0d452ed585a1590f5aeb to your computer and use it in GitHub Desktop.
Manage multiple versins of Go on MacOS with Homebrew

This process would likely apply to other Homebrew formula also.

First search for your desired package:

brew search go

You should get a list of results that include the below. Not "go" is very unspecific so you may get a lot of results:

==> Formulae
go ✔
go@1.10
go@1.11
go@1.9

Then install the desired version:

brew install go@1.10

Remember that you can have more than one package installed at the same time, but you cannot have them all available at the same time. So if you have the latest/generic go package already installed you need to unlink it first:

brew unlink go

And then you can link a different version:

brew link go@1.10

In some cases you may need to link them with the --force and --overwrite options:

brew link --force --overwrite go@1.10
@dnjmn
Copy link

dnjmn commented Jun 16, 2021

brew search go is not giving me the list of all versions of go

@ps-millar
Copy link

Hi @dnjmn,
I am using mac os Big Sir I ran brew install golang which installed the latest golang go1.16.5 in /usr/local/bin/go -> ../Cellar/go/1.16.5/bin/go. How do I get brew to install the Formulae or Caske for go version 1.13.4 or go1.13.4 ?

I need to use go1.13.4 on our project

@dnjmn
Copy link

dnjmn commented Jun 18, 2021 via email

@liiri
Copy link

liiri commented Oct 27, 2021

I think using Go's built in method to manage multiple versions might be less "violent": https://golang.org/doc/manage-install#installing-multiple

@ausaf007
Copy link

Awesome, this is really an elegant solution. Previously to use older version I had to play with alias (alias go="go1.19"), but this is really a clean to way to do it. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment