Open mondy opened 8 months ago
the issue title says subdirectory, but the report doesn't mention anything about directories?
the issue title says subdirectory, but the report doesn't mention anything about directories?
fyne.io/fyne/v2/cmd/fyne
is subdirectory.
cc @bcmills
go list -m
operates on modules, not packages. fyne.io/fyne/v2/cmd/fyne
is a package with the module fyne.io/fyne/v2
, not a module in its own right.
Normally, asking about a path that does not refer to a valid module results in an error, but in this case the error is suppressed by the -versions
flag. go list -m -json -versions fyne.io/fyne/v2/cmd/fyne
is successfully informing you that there are no known versions of that module in existence. It doesn't tell you an Origin
for a lack of such versions, because it doesn't know how to compute origins for things that don't exist.
Hmm, there might be an issue here, but it's subtle.
To give a bit more detail, https://go.dev/cl/543216 and https://go.dev/cl/543155 fixed some bugs in which cmd/go
was reporting incorrect Origin
metadata for mixed-origin data:
In this case, the mixed origin consists of:
cmd/fyne
at its latest commit, and does not contain any tags that would correspond to a module in that subdirectory, as well asgo-import
metadata.In theory, the Origin
structure does have enough metadata to represent both of those facts, as shown by the Origin
metadata returned for a query for @latest
(instead of -versions
):
$ GOPROXY=direct gotip list -m -e -json fyne.io/fyne/v2/cmd/fyne@latest
{
"Path": "fyne.io/fyne/v2/cmd/fyne",
"Version": "latest",
"Error": {
"Err": "module fyne.io/fyne/v2/cmd/fyne: no matching versions for query \"latest\""
},
"Origin": {
"VCS": "git",
"URL": "https://github.com/fyne-io/fyne",
"Subdir": "cmd/fyne",
"Hash": "e332a5e47813bff1af9631cbbfe84654c0143189",
"TagPrefix": "cmd/fyne/",
"TagSum": "t1:47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=",
"Ref": "HEAD"
}
}
(CC @matloob @samthanawalla @suzmue)
The reason I need this feature is related to #65350.
The feature I really want is to get an installable version with go install
.
Find the root directory by trimming Origin.Subdir
from the Path
of the retrieved JSON data. And Versions
can be reliably obtained from the root directory. I need the Origin
information for this.
If Origin
was intentionally erased (if it was decided as a specification), it may not be necessary.
Go version
go version go1.22.0 windows/amd64
Output of
go env
in your module/workspace:What did you do?
Execute
go list -m -json -versions fyne.io/fyne/v2/cmd/fyne
on go version 1.22.0 and 1.21.7.What did you see happen?
Execute
go list -m -json -versions fyne.io/fyne/v2/cmd/fyne
. Output:Origin field is not output.
Execute with go version 1.21.7.
Origin field is output.
What did you expect to see?
I would like to get the output of the Origin field in go version 1.22.0 as well.