gohomebrew

How to set GOROOT when installing via Brew?


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?


Solution

  • Some fixes: