Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.Sign up
x/tools/cmd/goimports: always choose internal copy over outer copy #10339
If someone is working in a tree where they have gone to the trouble to vendor a package, as long as the vendored copy is visible (not blocked by internal) we should make sure the vendored copy is always preferred. Otherwise goimports may hurt more than it helps in these situations.
Once there is a standard config file explaining what has been vendored, goimports could just read it and when it wants to use X but there's a vendored copy visible, use the vendored copy instead.
This came up in a private discussion with an external project about vendoring.
More than this, I want goimports to fail rather than choose a non-vendored option. This is,IMO, the strength of the model wherein I change GOPATH - goimports and every other tool simply do not know about the existence of non-vendored anything.
I'd rather see the go tool learn to read a local .gopath_override file or something, which I could check in with the repo, and then use non-rewriting vendoring.