c00m1g
Last Updated: February 25, 2016
·
4.042K
· infiniteloop5

Set $GOROOT variable with homebrew

If you are using go with homebrew on OSX, add this to your ~/.profile to set the $GOPATH automagically:

GOVERSION=$(brew list go | head -n 1 | cut -d '/' -f 6)
export GOROOT=$(brew --prefix)/Cellar/go/$GOVERSION/libexec
  • Update:

Added libexec, as suggested by @solidfox in the comments.

  • Update 2:

Setting the GOROOT variable should not be necessary in newer versions of go. If you really want to, use:

export GOROOT=$(go env GOROOT)

4 Responses
Add your response

15121

Beautiful thanks!

over 1 year ago ·
15654

Finally! Thanks

over 1 year ago ·
16445

Seems to work better with /libexec at the end. Is it wise to add this?

over 1 year ago ·
18079

I second @solidfox's comment. libexec needed.

over 1 year ago ·