dongye9991 2016-05-16 12:19
浏览 54
已采纳

Mac OS X上的GO(Golang)供应商实验失败

Having some trouble getting the go vendor experiment working with go 1.6.2 on osx.

Heres my directory structure:

/project
    /application
        main.go
        other.go
        /vendor
            /github.com
                /vendor_name
                    /package_name

I have my GOPATH set to /Users/me/project/application However when I try to run any of the go tools (e.g build) it seems to be looking in application/src rather than application/vendor, getting lots of this:

main.go:15:2: cannot find package "github.com/facebookgo/grace/gracehttp" in any of:
    /usr/local/Cellar/go/1.6.2/libexec/src/github.com/facebookgo/grace/gracehttp (from $GOROOT)
    /Users/me/project/application/src/github.com/facebookgo/grace/gracehttp (from $GOPATH)

As you can see for go env output vendor experiment is on by default as it should be it just doesnt seem to work:

GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/me/project/application"
GORACE=""
GOROOT="/usr/local/Cellar/go/1.6.2/libexec"
GOTOOLDIR="/usr/local/Cellar/go/1.6.2/libexec/pkg/tool/darwin_amd64"
GO15VENDOREXPERIMENT="1"
CC="clang"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fno-common"
CXX="clang++"
CGO_ENABLED="1"

Now, the source of the funkiness may be a hangover from previous go installations. I had installed various versions of go over time, some through gvm (go version manager) and some through homebrew. So I have uninstalled gvm and the versions of go it had installed, also unstalled go with homebrew and reinstalled just 1.6.2 using homebrew.

go version output:

go version go1.6.2 darwin/amd64

which go:

/usr/local/bin/go

Any ideas what may have gone wrong here, or am I perhaps just misunderstanding how vendoring should work?

P.S. Please elt me know if you need more info, happy to provide

  • 写回答

1条回答 默认 最新

  • dsrjs86444 2016-05-16 12:23
    关注

    it seems to be looking in application/src

    Yes, go is looking in $GOPATH/src, both for your sources and for vendor sources folders.

    Everything should be in $GOPATH/src

    The vendor folder is meant to be importable only by code in the directory tree rooted at the parent of "vendor".
    But it is part of your sources, and as such, should be under $GOPATH/src.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 西门子S7-Graph,S7-300,梯形图
  • ¥50 用易语言http 访问不了网页
  • ¥50 safari浏览器fetch提交数据后数据丢失问题
  • ¥15 matlab不知道怎么改,求解答!!
  • ¥15 永磁直线电机的电流环pi调不出来
  • ¥15 用stata实现聚类的代码
  • ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?
  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效
  • ¥15 悬赏!微信开发者工具报错,求帮改