本地管理go的不同版本管理,推荐使用: https://github.com/owenthereal/goup
安装
curl -sSf https://raw.githubusercontent.com/owenthereal/goup/master/install.sh | sh
更新PATH
执行之后,需要将Goup和Go的bin目录添加到PATH中:
Goup相关命令的bin目录:~/.go/bin
Golang相关命令的bin目录:~/.go/current/bin
在 安装了 oh-my-zsh之后,在 ~/.zshrc 中修改PATH
goup_bin=$HOME/.go/bin
go_bin=$HOME/.go/current/bin
export PATH=$goup_bin:$go_bin:$PATH
之后,新打开的终端,就能正常使用go和goup相关命令了。
⚠️如果当前shell也能运行go和goup相关命令,可以执行:
source $HOME/.go/env
更新GOPATH和GOBIN
go env -w GOPATH=/Users/youchaojiang/workspace/gopath
go env -w GOBIN=/Users/youchaojiang/workspace/gopath/bin
常见命令
![](https://img-blog.csdnimg.cn/fd4d5ad7cf53410687f233e25e2eaf8d.png)