猿问

不能再执行任何 go 命令

在它发生之前,我正在做的是尝试使用dep来管理我的golang代码依赖关系。我现在发现的是我无法使用go执行任何命令,即使我尝试使用brew by卸载它brew uninstall go并brew install go再次执行。


如果我这样做go env,它将显示如下:


$ go env

go: cannot find GOROOT directory: /usr/local/cellar/go/1.13.1/libexec


$ ls /usr/local/Cellar/go/1.13.8/libexec/

CONTRIBUTING.md SECURITY.md bin     lib     robots.txt

CONTRIBUTORS    VERSION     doc     misc        src

PATENTS     api     favicon.ico pkg     test


$ go version

go: cannot find GOROOT directory: /usr/local/cellar/go/1.13.1/libexec


$ go build

go: cannot find GOROOT directory: /usr/local/cellar/go/1.13.1/libexec


$ echo $GOPATH

/Users/mymac/go


$ echo $GOROOT


$

我应该怎么做和检查?


哈士奇WWW
浏览 110回答 2
2回答

子衿沉夜

我个人将其用于 Homebrewexport GOPATH=$HOME/goexport GOBIN=$GOPATH/bin# Homebrewexport GOROOT="$(brew --prefix golang)/libexec"# Manual install# export GOROOT=/usr/local/goexport PATH=$PATH:$GOPATH/binexport PATH=$PATH:$GOROOT/bin

慕虎7371278

试试这个:https://gist.github.com/vsouza/77e6b20520d07652ed7d# Set variables in .bashrc file# don't forget to change your path correctly!export GOPATH=$HOME/golangexport GOROOT=/usr/local/opt/go/libexecexport PATH=$PATH:$GOPATH/binexport PATH=$PATH:$GOROOT/bin当然,您需要将“$HOME/golang”和“/usr/local/opt/go:”更改为您的实际路径名。来自 OP:最后我解决了这个问题,你能帮忙更新你的评论然后我将它设置为 SOLVED。我用export GOROOT=/usr/local/Cellar/go/1.13.8/libexec/代替GOROOT=/usr/local/opt/go/libexec
随时随地看视频慕课网APP

相关分类

Go
我要回答