go: cmd/go: behavior of go list ... is not documented in module mode
go help packages
documents the special path all
both for gopath and module mode:
"all" expands to all packages found in all the GOPATH trees. For example, 'go list all' lists all the packages on the local system. When using modules, "all" expands to all packages in the main module and their dependencies, including dependencies needed by tests of any of those.
However the ...
pattern is documented only for gopath module:
An import path is a pattern if it includes one or more "..." wildcards, each of which can match any string, including the empty string and strings containing slashes. Such a pattern expands to all package directories found in the GOPATH trees with names matching the patterns.
How is the ...
pattern supposed to work in module mode?
As a test, I ran go list ... | wc -l
inside the github.com/golang/mod
(golang.org/x/mod
) directory with different versions of the go tool. The directory is outside GOPATH. The results are:
go1.11.13
: 501go1.12.16
: 526go1.13.8
: 632go1.14rc1
: 634
As a side note, how can I tell go list
to list only packages in the main module?
About this issue
- Original URL
- State: open
- Created 4 years ago
- Comments: 17 (17 by maintainers)
Ok, one last try 😄
@myitcv:
go list $(go list -m)/...
will catch packages in nested modules too.