Because there are many projects to maintain, and because these projects have different histories, some may have been written by myself, some have been taken over from others, one of the problems we are facing is that Go versions may not be consistent, but you don’t dare to take the risk of upgrading to a consistent version, after all, the test coverage is not enough to give me confidence to do so.
So, for now, I’m going to stick with the Go version specified by the project. So there is a need to use multiple versions of Go locally. This article is about the Mac environment, but it should actually work in the Linux environment as well.
Manage multiple environments via brew
Specify a version to run the code
If you don’t want to set a global fixed version, you can also specify a path to run a different version.
But you need to be careful with the
GOPATH environment variable. If you use the same
GOPATH for different versions of Go, once the higher version updates the dependent libraries, the lower version won’t work, very important.
Goland sets up multiple versions
Goland supports different versions of Go by default, and it can also download them for you.
If you think that’s not enough, then you can ask Goland to download one for you.
Various versions are available for you to choose from.
However, don’t forget to select a different
GOPATH after switching Go versions as well.