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)
Written by infiniteloop
Related protips
4 Responses

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
·
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Osx
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#