无法在 OSX Yosemite 上设置 Go 环境

Trouble setting up Go environment on OSX Yosemite

我已经使用 Homebrew 安装了 Go on OSX,这样我就可以安装 alpaca,但不断出现这样的错误:

package github.com/GeertJohan/go.rice/rice
    imports github.com/GeertJohan/go.incremental
    imports github.com/GeertJohan/go.rice/embedded
    imports github.com/akavel/rsrc/binutil
    imports github.com/akavel/rsrc/coff
    imports github.com/daaku/go.zipexe
    imports github.com/jessevdk/go-flags
    imports github.com/robertkrimen/terst
    imports testing: unrecognized import path "testing"
package github.com/GeertJohan/go.rice/rice
    imports github.com/GeertJohan/go.incremental
    imports github.com/GeertJohan/go.rice/embedded
    imports github.com/akavel/rsrc/binutil
    imports github.com/akavel/rsrc/coff
    imports github.com/daaku/go.zipexe
    imports github.com/jessevdk/go-flags
    imports github.com/robertkrimen/terst
    imports bitbucket.org/kardianos/osext
    imports bitbucket.org/pkg/inflect
    imports unicode: unrecognized import path "unicode"
make: *** [deps] Error 1

谷歌搜索似乎问题出在我的 go 环境上,但我似乎无法弄清楚如何解决这个问题。这是我在 运行 go env:

时看到的
GOARCH="amd64"
GOBIN=""
GOCHAR="6"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/mc/go"
GORACE=""
GOROOT="/Users/mc/go/packages"
GOTOOLDIR="/Users/mc/go/packages/pkg/tool/darwin_amd64"
CC="clang"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fno-common"
CXX="clang++"
CGO_ENABLED="1"

我哪里错了?

好的,@not_a_golfer 的评论帮助我解决了这个问题——GOROOT 需要在 brew 安装 Go 的地方。

在我的案例中 export GOROOT=/usr/local/Cellar/go/1.4.1/libexec 已解决。

GOROOT="/Users/mc/go/packages" 不正确。

您不必设置 GOROOT。查看 Dave Cheney 的 blog post