Open
Description
Currently, if you run go mod why -m
on the output of every module in go list -m all
, some modules may come back with the answer (main module does not need module […])
, even after a go mod tidy
.
The reason is that the module graph is conservative: go list -m all
answers the question “which module versions are implied by the requirements of the main module?”, not “which modules does the main module need to download to complete go list all
?”.¹
In contrast, go mod why
explicitly ties its answer to go list all
.
We should have some flag to go mod why
to answer the related go list -m all
question, “what path of requirements imposes the version requirement on module x
?”
¹The command to answer the latter question, as it turns out, is:
go list -f '{{with .Module}}{{.Path}} {{.Version}}{{end}}' all | sort -u