dongye9991 2016-05-16 04: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 04: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.

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

报告相同问题?

悬赏问题

  • ¥15 PADS Logic 原理图
  • ¥15 PADS Logic 图标
  • ¥15 电脑和power bi环境都是英文如何将日期层次结构转换成英文
  • ¥20 气象站点数据求取中~
  • ¥15 如何获取APP内弹出的网址链接
  • ¥15 wifi 图标不见了 不知道怎么办 上不了网 变成小地球了
手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部