gvm 是什么 gvm(Go Version Manager) 是一个 Go 的本地版本管理工具 如何安装 bash < <(curl -s -S -L https://raw.githubusercontent.com/moovweb/gvm/master/binscripts/gvm-installer) 执行 source /Users/vuri/.gvm/scripts/gvm 或重启你的终端 Session 以生效 gvm help Usage: gvm [command] Description: GVM is the Go Version Manager Commands: version - print the gvm version number get - gets the latest code (for debugging) use - select a go version to use (--default to set permanently) diff - view changes to Go root help - display this usage text implode - completely remove gvm install - install go versions uninstall - uninstall go versions cross - install go cross compilers linkthis - link this directory into GOPATH list - list installed go versions listall - list available versions alias - manage go version aliases pkgset - manage go packages sets pkgenv - edit the environment for a package set applymod - apply the go version in go.mod 列出本地可用版本 $ gvm list gvm gos (installed) system 安装指定版本 $ gvm install go1.21.0 Installing go1.21.0... * Compiling... go1.21.0 successfully installed! 使用指定版本 $ gvm use go1.21.0 Now using version go1.21.0 $ go version go version go1.21.0 darwin/amd64 结合 fzf 来指定版本 $ gvm use $(ls -1 $GVM_ROOT | fzf) Now using version go1.21.0 $ gvm use $(ls -1 $GVM_ROOT | fzf) Now using version go1.18.10 删除指定版本 $ gvm uninstall go1.21.0 列出所有的 go 版本 $ gvm listall ... go1.21.0 go1.21.1 go1.21.2 go1.21.3 go1.21.4 go1.21.5 ...