记录 Go 语言 GOROOT设置 go: cannot find GOROOT directory: /usr/local/Cellar/go/1.13.1/libexec
这个问题出现的原因是你的环境变量不存在了。
如果你是mac/linux, 在命令行输出which go
比如我的 显示/usr/local/go/bin/go, 那么GOROOT就应该是/usr/local/go
vim ~/.bash_profile
使用vim设置环境变量
GOROOT=/usr/local/go
export GOROOT
然后保存
这个时候就应该可以了。
可是,我已经修改了还是不行,我鼓捣了半天,终于搜索到了。
注意新的mac 默认是 zsh ,这时候 .bash_profile 不起效果, 需要 vim ~/.zshrc
,在最后一行加入source ~/.bash_profile 即可。