duanpiyao2734
2015-07-27 21:36
浏览 20
已采纳

无法通过自制程序安装在OS X上导入net / http的程序

I've installed go using Homebrew on my OS X 10.10 machine. Every time I try to compile a sample app that imports net/http, I get the following error:

load cmd/cgo: package cmd/cgo: no Go source files in /Users/bbaron/google_appengine/goroot/src/cmd/cgo

I have my GOPATH variable set correctly ($HOME/go) and my directory structure appears to be correct:

/Users/bbaron/go/src/github.com/einsteinx2/gamenotifier /Users/bbaron/go/src/github.com/einsteinx2/gamenotifier/server.go

Why does cgo seem to thing the GOPATH is $HOME/google_appengine/goroot

I previously (maybe a year ago) did some go development using App Engine, so there must be some left over garbage, but I can't figure out what I need to change to get this working.

I do have the App Engine SDK installed to $HOME/google_appengine but I don't see why that's affecting anything when I'm not importing any App Engine stuff.

Any ideas?

EDIT: It looks like the problem is my GOROOT. The following are also in go env:

GOROOT="/Users/bbaron/google_appengine/goroot" GOTOOLDIR="/Users/bbaron/google_appengine/goroot/pkg/tool/darwin_amd64"

But even if I export a correct GOROOT and check with echo $GOROOT, go env does not see the correct GOROOT

图片转代码服务由CSDN问答提供 功能建议

我已经在OS X 10.10计算机上使用Homebrew安装了go。 每次我尝试编译导入net / http的示例应用程序时,都会出现以下错误:

load cmd / cgo:程序包cmd / cgo:/ Users /中没有Go源文件 bbaron / google_appengine / goroot / src / cmd / cgo

我正确设置了我的GOPATH变量($ HOME / go),并且目录结构似乎是正确的:

/Users/bbaron/go/src/github.com/einsteinx2/gamenotifier /Users/bbaron/go/src/github.com/einsteinx2/gamenotifier/server.go \ n

为什么cgo看起来GOPATH是$ HOME / google_appengine / goroot

我以前(也许一年前)使用App Engine进行了一些开发,所以必须 一些剩余的垃圾,但我无法弄清楚需要什么才能使它正常工作。

我确实将App Engine SDK安装到$ HOME / google_appengine,但我没有 没看到为什么当我不导入任何App Engine东西时会影响什么。

任何想法?

编辑:看来问题出在 我的天哪 以下内容也在go env中:

GOROOT =“ / Users / bbaron / google_appengine / goroot” GOTOOLDIR =“ / Users / bbaron / google_appengine / goroot / pkg / tool / darwin_amd64”

但是,即使我导出正确的GOROOT并使用echo $ GOROOT进行检查,go env也看不到正确的GOROOT

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • doutan1970 2015-07-27 23:22
    已采纳

    It turned out that my google app engine installation was clobbering these environment variables somehow. I deleted the folder google_appengine in my home directory and then uninstalled the Homebrew version of Go and reinstalled from the official OS X package and now it's working fine.

    点赞 打赏 评论

相关推荐 更多相似问题