Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/go: Go project using library from another vendor folder under the same $GOPATH causing type error #17822

Closed
EwanValentine opened this issue Nov 6, 2016 · 2 comments

Comments

@EwanValentine
Copy link

EwanValentine commented Nov 6, 2016

Please answer these questions before submitting your issue. Thanks!

What version of Go are you using (go version)?

Go 1.7.3

What operating system and processor architecture are you using (go env)?

GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/ewanvalentine/go"
GORACE=""
GOROOT="/usr/local/go"
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
CC="clang"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/n
b/mc8yq3sn31j8_jfw_0xdhgc40000gn/T/go-build624813324=/tmp/go-build -gno-record-gcc-switches -fno-common"
CXX="clang++"
CGO_ENABLED="1"

What did you do?

Ran...

$ govendor add google.golang.org/grpc
$ govendor add google.golang.org/grpc/internal 

In project A, then...

$ govendor add google.golang.org/grpc
$ govendor add google.golang.org/grpc/internal

In project B.

What did you expect to see?

I expected to have access to the google gRPC library from the local vendor folder.

What did you see instead?

The gRPC library from another project in the same $GOPATH was being used instead, causing a 'incorrect type' error.

./main.go:44: cannot use conn (type *"bitbucket.org/bandzest/bandzest-service-artists/api/vendor/google.golang.org/grpc".Clien
tConn) as type *"bitbucket.org/bandzest/bandzest-service-auth/api/vendor/google.golang.org/grpc".ClientConn in argument to pro
to.NewAuthClient
@josharian josharian changed the title Go project using library from another vendor folder under the same $GOPATH causing type error cmd/go: Go project using library from another vendor folder under the same $GOPATH causing type error Nov 7, 2016
@freeformz
Copy link

If project A imports project B, project B needs to be added to project A's vendor folder by a tool like govendor so that it can flatten out the dependency graph so there is only one version of each dependency for project A.

@quentinmit
Copy link
Contributor

This sounds like it is WAI. Go treats each vendored package as a separate package. If you want to use types from one vendored library across two packages, those packages need to share a single library in a single vendor directory.

If you don't think that's what is happening here, please provide a complete test case (with two packages) and we can try to reproduce.

@golang golang locked and limited conversation to collaborators Nov 7, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants