duan19911992 2016-09-12 19:40
浏览 19
已采纳

go1.7无法识别供应商目录

I have a package which I'm trying to vendorize. It uses the capnproto2 package. It builds without error when the package is under $GOPATH/src/zombiezen.com/go/capnproto2 but fails when I move it to my vendor directory. My project is located under my GOPATH.

$ go build
../fram/rim/fsd.go:7:8: cannot find package "zombiezen.com/go/capnproto2" in any of:
    /home/mjohn/software/go/src/zombiezen.com/go/capnproto2 (from $GOROOT)
    /home/mjohn/workspace/gopath/src/zombiezen.com/go/capnproto2 (from $GOPATH)
../fram/rim/schema.capnp.go:7:2: cannot find package "zombiezen.com/go/capnproto2/encoding/text" in any of:
    /home/mjohn/software/go/src/zombiezen.com/go/capnproto2/encoding/text (from $GOROOT)
    /home/mjohn/workspace/gopath/src/zombiezen.com/go/capnproto2/encoding/text (from $GOPATH)
../fram/rim/schema.capnp.go:8:2: cannot find package "zombiezen.com/go/capnproto2/schemas" in any of:
    /home/mjohn/software/go/src/zombiezen.com/go/capnproto2/schemas (from $GOROOT)
    /home/mjohn/workspace/gopath/src/zombiezen.com/go/capnproto2/schemas (from $GOPATH)

My environment:

$ go env
GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/mjohn/workspace/gopath"
GORACE=""
GOROOT="/home/mjohn/software/go"
GOTOOLDIR="/home/mjohn/software/go/pkg/tool/linux_amd64"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build069056451=/tmp/go-build -gno-record-gcc-switches"
CXX="g++"
CGO_ENABLED="1"

My project layout

$ pwd
/home/mjohn/workspace/gopath/src/mjohn/msg

$ ls
cmd/main.go
cmd/rpc.go
vendor/zombiezen.com/go/capnproto2

Obviously there's more in the capnproto2 directory, but this was a copy from $GOPATH/src/zombiezen.com/go/capnproto2.

Any ideas on why go doesn't recognize my vendor directory?

Thank you.

  • 写回答

1条回答 默认 最新

  • duanshan5259 2016-09-12 20:13
    关注

    The package mjohn/fram/rim is what is failing to import zombiezen.com/go/capnproto2, but the vendor directory is in the mjohn/msg package.

    You can either vendor mjohn/fram/rim in it's entirety, including dependencies inside the mjohn/msg package, or you can vendor zombiezen.com/go/capnproto2 in the mjohn/fram/rim package where it's imported.

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

报告相同问题?