英文:
How to set GOROOT when installing via Brew?
问题
这里的错误是GOROOT变量设置不正确。根据你提供的信息,GOROOT应该设置为/opt/homebrew/Cellar/go/1.19.2
而不是/opt/homebrew/Cellar/go/1.19.2/bin/go/libexec
。请将GOROOT变量更正为正确的路径。以下是正确的设置示例:
export GOROOT=/opt/homebrew/Cellar/go/1.19.2
export GOPATH=$HOME/go
export PATH=$PATH:$GOROOT/bin:$GOPATH/bin
请注意,我只提供了翻译,不会回答关于翻译内容的问题。
英文:
I installed Go with the following command:
brew install go
It is now installed under /opt/homebrew/Cellar/go/1.19.2
I than set the variables like so:
export GOROOT=/opt/homebrew/Cellar/go/1.19.2/bin/go/libexec
export GOPATH=$HOME/go
export PATH=$PATH:$GOPATH/bin
When I try go env
I get this:
go: cannot find GOROOT directory: /opt/homebrew/Cellar/go/1.19.2/bin/go/libexec
What is the mistake here?
答案1
得分: 8
一些修复:
export GOROOT="$(brew --prefix golang)/libexec"
- 不要设置GOROOT
- 使用官方安装程序而不是brew(推荐)。
英文:
Some fixes:
export GOROOT="$(brew --prefix golang)/libexec"
- Do not set GOROOT
- Use official installer instead of brew (recommended).
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论