LoginSignup
0
0

More than 5 years have passed since last update.

(設定する必要がなかった!)homebrew で入れた go に GOROOT を設定する

Last updated at Posted at 2013-12-05

追記: 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
0
0
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0