How to set GOROOT when installing via Brew?

huangapple go评论74阅读模式
英文:

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).

huangapple
  • 本文由 发表于 2022年10月6日 04:53:24
  • 转载请务必保留本文链接:https://go.coder-hub.com/73966233.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定