Multi version management of golang in Windows


Multi version management of golang in Windows

currentgolangThere are still some incompatibilities among different versions. Recently, we encountered some problemsgo-microThe framework can only run in go 1.13 ~ 1.14, but I installed it under windows1.15So you need to install other versions of golang, so many versionsgolangHow to useWindowsIt’s coexistence on the Internet.

If you find that the command does not work during the following operation, you can open a new command line window and try again.

Next, I will introduce the four solutions I have tried. The best solution is the fourth one, and the first and third failed.

Create directory and change path

Install golang in windows and run it in CMD

$ go verstion
go version go1.15.2 windows/amd64

Because it is configured in the path variablegoOfbinDirectory, so it can run directly in CMDgo.exe
Multi version management of golang in Windows

Can I create a new folder without deleting the original golangC:\Go1.13To store our new version of golang.

Run the newly downloaded setup

Multi version management of golang in Windows

choiceUninstallIt doesn’t matter. We’ve got itPATHRemoved. He can’t find the deleted directory.

Enter the new directory we configured for him
Multi version management of golang in Windows

After the installation, I was dumbfounded, other files are installed in theC:\Go1.13And this is installed in theC:\GoIn the catalogue

Multi version management of golang in Windows

The previous installationGo1.15.2It was unloaded. I just want to create a directoryC:\Go1.15.2, to re install go 1.13.14, I deleted the path, but it still found the file and deleted it.

Multi version management of golang in Windows

Therefore, it is not feasible to install different versions of golang through multiple directories.

go get

This isOfficial advice

#You can also get other versions of golang
$ go get

#Download this step can not be less
$ go1.15.2 download

#Check it out
$ go1.15.2 version
go version go1.15.2 windows/amd64

#Default golang version
$ go version
go version go1.13.14 windows/amd64

Newly installedgo1.15.2.exestay%USERPROFILE%\go\binUnder the directory

Note that the above methods need to access Google services, so you understand.

You not only need to set HTTP proxy, but also need to set git global proxy!



The following commands are run in Git bash environment, not windows CMD environment!

this paperaddress


$ bash < <(curl -s -S -L

#Proxy access
$ bash < <(curl -x socks5://james:[email protected]:8080 -s -S -L

Cloning from to /c/Users/wojia/.gvm
Created profile for existing install of Go at C:\Users\wojia\.g\go
Installed GVM v1.0.22

Please restart your terminal session or to get started right away run
 `source /c/Users/w/.gvm/scripts/gvm`

The last line prompts us to open a new terminal and run the commandsource /c/Users/w/.gvm/scripts/gvmLet’s see what’s going on inside.

$ cat /c/Users/w/.gvm/scripts/gvm

export GVM_ROOT=/c/Users/w/.gvm
. $GVM_ROOT/scripts/gvm-default

This is obviously a configuration script.

to configure

Add GVM in Windows_ After the root environment variable, take a look at the configuration script.

cat $GVM_ROOT/scripts/gvm-default
unset GOROOT
unset GOARCH
unset GOOS
unset GOPATH
unset GOBIN

unset gvm_go_name
unset gvm_pkgset_name

mkdir -p "$GVM_ROOT/logs" > /dev/null 2>&1
mkdir -p "$GVM_ROOT/gos" > /dev/null 2>&1
mkdir -p "$GVM_ROOT/archive" > /dev/null 2>&1
mkdir -p "$GVM_ROOT/archive/package" > /dev/null 2>&1
mkdir -p "$GVM_ROOT/environments" > /dev/null 2>&1

export PATH="$GVM_ROOT/bin:$PATH"
[ -f "$GVM_ROOT/environments/default" ] && . "$GVM_ROOT/environments/default"
. "$GVM_ROOT/scripts/env/gvm"

In other words, you need to configure environment variablesGVM_VERSIONGVM_PATH_BACKUP, PATH


After configuration, try it.

$ gvm install go1.4
C:\Users\w\.gvm/scripts/functions: line 3: C:\Users\w\.gvm/scripts/function/*: No such file or directory

It seems that shell script is not adjusted for windows, and GVM is not compatible with windows.


Finally, let’s take a lookg


For windows, go directly to GitHub release page to download the target file:

Multi version management of golang in Windows

Directly decompress theg.exePut inPATHJust drop it in the directory

$ g -v
g version 1.2.0

#Installation successful!

to configure

For windows, the originalC:/Go/binfromPATHRemove from, add to%USERPROFILE%\.g\go\bin

If GoLand import reports an error, it needs to be adjustedGOROOT, GOPATHto configure

Multi version management of golang in Windows

It needs to be adjusted toC:\Users\w\.g\gocatalog.


Query currently available for installationstableThe go version of the state

$ g ls-remote stable

Install target go version1.14.7

$ g install 1.14.7
Downloading 100% |███████████████| (119/119 MB, 9.939 MB/s) [12s:0s]
Computing checksum with SHA256
Checksums matched
Now using go1.14.7

Query the version of go that has been installed locally

$ g ls
* 1.14.7

Query all go versions available for installation

$ g ls-remote
  ... // omit several versions
* 1.14.7

Switch to another installed version of go

$ g use 1.14.6
go version go1.14.6 darwin/amd64

Uninstall an installed version of go

$ g uninstall 1.14.7
Uninstalled go1.14.7


For now (October 2020), the,gyesWindowsThe best in the worldgolangMulti version management software,golangThe official plan is also good, but it worksgoCommands need to add version number, easy and easyshellScript coupling.

gvmNot yet adaptedWindows. Open more folders and changePATHIt’s just a joke. Let’s have fun.

reference resources

This work adoptsCC agreementReprint must indicate the author and the link of this article

Recommended Today

Quickly use the latest 15 common APIs of vue3

Before that, I wrote a blog to introduce the new features of vue3. I had a brief understanding of the features of vue3, and at the end of the article, I gave you a little experience in vue3Compsition APISimple use of Address of last article: follow Youda’s steps and experience the new features of vue3 […]