通过 Brew 安装时如何设置 GOROOT?

我使用以下命令安装了 Go:


brew install go


现在安装在/opt/homebrew/Cellar/go/1.19.2


我比这样设置变量:


export GOROOT=/opt/homebrew/Cellar/go/1.19.2/bin/go/libexec

export GOPATH=$HOME/go

export PATH=$PATH:$GOPATH/bin

当我尝试时,go env我得到了这个:


go: cannot find GOROOT directory: /opt/homebrew/Cellar/go/1.19.2/bin/go/libexec


这里有什么错误?


慕工程0101907
浏览 300回答 1
1回答

呼如林

一些修复:export GOROOT="$(brew --prefix golang)/libexec"不要设置 GOROOT使用官方安装程序而不是 brew(推荐)。
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Go