追記: go を homebrew で入れた場合 GOROOT は必要ありません。勘違いしていました!
これまで /usr/local/Cellar/go/{version}
だったようですが、go 1.2 では /usr/local/Cellar/go/{version}/libexec
を指定しないと動きません。
出回ってた ivanzoid さんのスクリプトを go 1.2 用に修正したのが以下。.bashrc とか .bash_profile に置いとくといいです。
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/../libexec; pwd`
}
setupGOROOT
fi