Brew
is a package management tool on Mac, just like apt
, yum
, rpm
on Linux, which can provide non-graphical software installation. Yesterday, while building the most powerful IDE in the universe, I used the brew
tool to update the packages. Upgraded my Go version to the latest version, and wiped out the previously configured multiple versions of Go.
Option 1 brew switch
1. brew install
|
|
By default you can install the latest version of go, and then install the specified version, using the brew switch
command to switch between them.
2. brew switch
Using the brew info go
command you can see the current versions of go that you can switch to, so you can install multiple versions and switch to the corresponding version.
Once installed, use brew info go
to see if the switch is ready.
|
|
Using the above command alone you will find that go does not work anymore and the following message will appear.
Having created zero links means that it did not successfully point the go version under the version you need, what is the problem? Now cut the go version back to go 1.15.3 and you will find that you can switch and use it normally.
To locate this you need to look at why softlinks were not created for go version 1.12.17. The first step is to find where go is installed by default, use go env
to see the installation directory.
|
|
Use the brew utility in the location of the MacOS Catalina system installation.
After entering the directory, there is only the default version 1.15.3 installed in the go directory, and there is no version installed by you, so you can exit the parent directory and see the downloaded version of go@1.12.17. Since the soft link is linked to the path above, you need to move this directory to the go directory.
Next, use the switch command brew switch go <version>
to switch environments.
Option 2 brew link
Verify with Homebrew 3.2.9.