1

I have projectA which imports packages from projectB. Both are existing in the GOPATH. I use dep for dependency management and projectB is added as a dependency in the Gopkg.toml of the projectA.

If I clear this projectB from the vendor directory of projectA or if I add it explicitly to the ignored = ["projectB"] It compiles fine. Otherwise I get the kind of following errors:

"gitlab.internal.com/client/vendor/gitlab.internal.com/runtime/protocol/client".Connector does not implement "gitlab.internal.com/runtime/protocol/client".Connector (wrong type for ApplicationContext method)
        have ApplicationContext() *"gitlab.internal.com/client/vendor/gitlab.internal.com/runtime/core".ApplicationContext
        want ApplicationContext() *"gitlab.internal.com/runtime/core".ApplicationContext

The only difference from the 'have' and 'want' packages above is the path from where it is coming from. (One from GOPATH, the other from vendor/ of the projectA, which has this compilation issue)

I have the following questions:

  1. Why is GOPATH being searched at all, given it is available in the vendor/? (Why does it state it 'wants' the dependency only from this place!?)
  2. Is there a way to get the dep pick the dependency explicitly from vendor/?

Deleting the projectB from the GOPATH doesn't solve the problem either. What is the issue here?

gkns
  • 697
  • 2
  • 12
  • 32
  • You should never have a package with a `vendor/` directory vendored in your project (or more loosely, you can't depend on a package with a `vendor/` directory -- i.e. "libraries" shouldn't vendor their dependencies). Whatever tools you are using should have a way to flatten the vendored dependencies into your top-level project. If you have the ability to change over now, go modules makes this much easier to do. – JimB Apr 05 '19 at 14:59

0 Answers0