這個問題出現的原因是你的環境變量不存在了。
如果你是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 即可。