Last Updated: February 25, 2016
·
5.331K
· 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

Beautiful thanks!

over 1 year ago ·

Finally! Thanks

over 1 year ago ·

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

over 1 year ago ·

I second @solidfox's comment. libexec needed.

over 1 year ago ·