-
Notifications
You must be signed in to change notification settings - Fork 17.7k
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: backported module awareness doesn't support list or go/build #25662
Comments
CC @andybons This is a potential blocker for a 1.10.3 release. |
I’m guessing this will also require a backport to 1.9 as well. |
If this issue is confirmed as indeed an issue (i.e. assumptions/expectations aren't off) then yes, I suspect so. /cc @bcmills too |
Thanks very much for trying these out Paul. I really appreciate the scrutiny. While I admit the behavior here is a little difficult to understand, it's working as intended. The key point about the change for #25069 is that it only applies to new (go.mod-containing) code that is itself imported from new (go.mod-containing) code. It is intentional that if you are compiling code that is outside a go.mod tree, the correct import path is still github.com/myitcv/vgo_example_compat. Only inside a go.mod source tree, an import github.com/myitcv/vgo_example_compat/v2 is read as if it really said github.com/myitcv/vgo_example_compat. For example I just created github.com/rsc/vgotest4 and github.com/vgotest5, which both import your code. vgotest4 has no go.mod so it imports as github.com/myitcv/vgo_example_compat, while vgotest5 does have a go.mod, so it imports as github.com/myitcv/vgo_example_compat/v2. The other key part is the "is read as if it really said". Just like with vendor, on the go command line you have to use the "real" import paths not the rewritten ones that might appear in your code. For example if you have a GOPATH in which x/y/vendor/z/w exists and you are in the x/y directory, "go list z/w" may well assuming, since GOPATH/src/z/w does not also exist. What you have to say on the command line is the "real" path, x/y/vendor/z/w, even though x/y/y.go might say import "z/w". That import is read as if it really said x/y/vendor/z/w, per golang.org/s/go15vendor. The same thing is happening here: there is a by-design disconnect between what's in the import paths and what you have to say to the go command. The new v2-containing path is (in the old legacy go command) this one special case essentially limited to the import reader in module-aware source files, not something you can use more generally. go get github.com/rsc/vgotest4 all work for me (my go1.10 has the release branch CLs). What doesn't work for me is go1.9 get github.com/rsc/vgotest5 I have to run out now but I will look into that in a few hours. Filed #25687 for that. |
Thanks, Russ; totally makes sense now. Really appreciate the full explanation. Regarding the Do we therefore, with the release of Go 1.11, gain an |
Yes, go/build's build.Import does not handle vgo. Nor does it handle some aspects of build caching. We are trying to get a replacement package, tentatively named golang.org/x/tools/go/packages, out soon. |
Ah great, so this is indeed part of the work Alan mentioned a few weeks ago. Thanks for confirming. |
Please answer these questions before submitting your issue. Thanks!
What version of Go are you using (
go version
)?which is on the
release-branch.go1.10
branch, and includes https://go-review.googlesource.com/c/go/+/114500.Does this issue reproduce with the latest release?
n/a
What operating system and processor architecture are you using (
go env
)?What did you do?
Use the Go 1.10 backport branch, specifically:
Get vgo:
Create a simple module that depends on v2 of a package, and build:
Now try to go get v2:
Note that this works (unsuprisingly):
Now try and build:
Now try and list v2 of the package on which we depend:
Note that this works:
Now verify how go/build behaves with these imports paths:
Run for the v2 import path:
Note that this works:
What did you expect to see?
I'm unclear whether we should/would expect
go list
etc to work with the backported changes for*/v2/*
import paths?Also I note that
go/build
could/should have these resolution powers too?What did you see instead?
The Go 1.10 backported changes not working for
go list
or via use ofgo/build
for*/v2/*
import paths./cc @rsc
The text was updated successfully, but these errors were encountered: