Go 语言设置 GOPATH 环境变量被重置

我用下面这条命令设置 GOPATH 路径

export GOPATH=$HOME/go

能生效,但是每次重新开终端执行 go get 命令又提示,为什么呢?

package xxx: cannot download, $GOPATH not set. For more details see: go help gopath

阅读 15.9k
3 个回答

bash的话,配置到.profile或者.bashrc
zsh的话,配置到.zshrc

将export写到~/.profile中,重开终端执行. ~/.profile

推荐问题