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

Fix importing of vendored packages #136

Merged
merged 1 commit into from
Jul 19, 2019

Conversation

nkovacs
Copy link
Contributor

@nkovacs nkovacs commented Jul 15, 2019

x/tools/go/packages does not search inside vendor.
Work around by using build.Import first to find the package in vendor.
See golang/go#30289

There aren't any tests with a vendor directory, so I only tested this manually on a project that uses it and wants to generate a fake for a vendored package. I can try to write some test fixtures if you'd like.

Fixes #75

x/tools/go/packages does not search inside vendor.
Work around by using build.Import first to find the package in vendor.
See golang/go#30289
@nkovacs
Copy link
Contributor Author

nkovacs commented Jul 15, 2019

Note that build.Import has a bug in go 1.13beta1 and does not work properly when GO111MODULE=auto and the directory is in GOPATH and has go.mod (or a parent directory does). This doesn't affect the tests, because they explicitly set GO111MODULE to "on" or "off", and it doesn't affect 1.12, because "auto" does not activate module mode in GOPATH under 1.12 (forcing you to use GO111MODULE=on anyway).
x/tools/go/packages does not have this bug, so technically this change breaks counterfeiter under go 1.13beta1 with a module in GOPATH unless you explicitly use GO111MODULE=on, but the bug is fixed in go tip.

@joefitzgerald joefitzgerald merged commit f85ca4b into maxbrunsfeld:master Jul 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

counterfeiter does not check vendor directory when generating using import path
2 participants