Join GitHub today
cmd/go: backported module awareness doesn't support list or go/build #25662
Please answer these questions before submitting your issue. Thanks!
What version of Go are you using (
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.
Do we therefore, with the release of Go 1.11, gain an