Skip to content

Instantly share code, notes, and snippets.

@nelsonjchen
Forked from ivanzoid/setupGOROOT.sh
Last active January 1, 2016 22:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nelsonjchen/8212392 to your computer and use it in GitHub Desktop.
Save nelsonjchen/8212392 to your computer and use it in GitHub Desktop.
#
# Place this code to your .profile, .bashrc, .bash_profile or whatever
#
program_exists () {
type "$1" &> /dev/null ;
}
if program_exists go; then
function setupGOROOT()
{
local GOPATH=`which go`
local GODIR=`dirname $GOPATH`
local GOPATH_BREW_RELATIVE=`readlink $GOPATH`
local GOPATH_BREW=`dirname $GOPATH_BREW_RELATIVE`
export GOROOT=`cd $GODIR; cd $GOPATH_BREW/..; pwd`
# For mtoader/google-go-lang-idea-plugin/
launchctl setenv GOROOT $GOROOT
launchctl setenv GOPATH $GOPATH
}
setupGOROOT
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment