-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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: reference to v2 module incorrectly using subdirectory of module #28083
Comments
In the first case you are asking for the version of a module within the source tree for that module. To my mind the version of a module in this situation is undefined.
In the second case you are querying a module as a dependency (that is present within the readonly-module cache). In this situation the module has been resolved via MVS and hence has a version associated with it.
What version would you expect to be returned in the first instance out of interest? |
Thanks for the explanation @myitcv . That makes sense. $ pwd /tmp/explist2 $ tree . ├── f.go ├── go.mod ├── go.sum └── v2 ├── f.go ├── go.mod └── go.sum $ go list -f '{{.ImportPath}} in {{.Module.Path}}@{{.Module.Version}}' github.com/hyangah/explist2/v2 github.com/hyangah/explist2/v2 in github.com/hyangah/explist2@ The v2 is set up following the major subdirectory model. I expect querying v2 from the repo root directory to return the same result as the query outside the repo. But it does not. Moreover, it doesn't seem to recognize the If I query from the v2 directory, at list the go list seemed to recognize $ cd v2 $ go list -f '{{.ImportPath}} in {{.Module.Path}}@{{.Module.Version}}' github.com/hyangah/explist2/v2 github.com/hyangah/explist2/v2 in github.com/hyangah/explist2/v2@ |
I don't think the cc @bcmills who will undoubtedly be tighter on the wording/definitions here than I am. |
go list
without -m gives different answers depending on where the command runsgo list
without -m does not recognize the go.mod file in its subdirectory
I should've used better wording. Even when I added a dependency on v2 from v1, the result is same. $ cat f.go package explist2 import "github.com/hyangah/explist2/v2" var Name = explist2.Name $ cat go.mod module github.com/hyangah/explist2 require github.com/hyangah/explist2/v2 v2.0.1 $ go list -f '{{.ImportPath}} in {{.Module.Path}}@{{.Module.Version}}' github.com/hyangah/explist2/v2 github.com/hyangah/explist2/v2 in github.com/hyangah/explist2@ |
go list
without -m does not recognize the go.mod file in its subdirectory
I don't know what was going on before, but as far as I can tell this is working as designed with The
|
In the source tree of the queried package (and its module)
vs.
The text was updated successfully, but these errors were encountered: