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: go list
reports all dependencies as indirect with workspaces
#66789
Comments
can you provide a complete reproducer? |
I tried running this command (with xxx=all) from within golang.org/x/tools, both with and without a go.work file: With:
Without go.work:
I am surprised that golang.org/x/sync is considered indirect in the first case but a direct dependency in the second case, as it is
Perhaps @matloob can shed some light on it. |
go list
Indirect Dependencies Doesn't Work on Worksapcego list
reports all dependencies as indirect with workspaces
Ah it looks like we just never set the direct field in the requirements structure for workspaces. The reason the main modules had the correct direct value is because the moduleInfo function just bypasses checking direct and creates the module struct through a different code path which doesn't set the indirect field. I've prepared a CL (580256) to fix this... Just need to add some tests and I'll mail it out |
Change https://go.dev/cl/580256 mentions this issue: |
Go version
go version go1.22.2 darwin/arm64
Output of
go env
in your module/workspace:What did you do?
Tried to run
go list -f '{{if not (or .Main .Indirect)}}{{.Path}}{{end}}' -m xxx
to get the direct dependencies of one module on a workspace with multiple modulesWhat did you see happen?
The command outputs nothing, i.e. all direct dependencies of the module are discovered as indirect dependencies
What did you expect to see?
The command should show the direct dependencies of the module
The text was updated successfully, but these errors were encountered: