英文:
Trouble setting up Go environment on OSX Yosemite
问题
我已经在OSX上使用Homebrew安装了Go,以便我可以安装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"
我在这里做错了什么?
英文:
I've installed Go on OSX using Homebrew so that I could install alpaca, but keep getting errors like this:
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
Googling around it seems the issue is with my go environment, but I can't seem to figure out how to resolve this. Here's what I see when I run 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"
What am I getting wrong here?
答案1
得分: 1
好的,以下是翻译好的内容:
好的,@not_a_golfer的评论帮助我解决了这个问题 - GOROOT需要设置为brew安装Go的位置。
在我的情况下,export GOROOT=/usr/local/Cellar/go/1.4.1/libexec
解决了这个问题。
英文:
Okay, @not_a_golfer 's comment helped me figure this out -- the GOROOT needs to be where brew installed Go.
In my case export GOROOT=/usr/local/Cellar/go/1.4.1/libexec
resolved it.
答案2
得分: 0
GOROOT="/Users/mc/go/packages"
是不正确的。
你不需要设置 GOROOT
。请查看 Dave Cheney 的这篇博文。
英文:
GOROOT="/Users/mc/go/packages"
is incorrect.
You should not have to set your GOROOT
. checkout out this blog post by Dave Cheney.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论