env GO111MODULE=on
[short] skip
cd m
# 'go list all' should list all of the packages used (directly or indirectly) by
# the packages in the main module, but no other packages from the standard
# library or active modules.
#
# 'go list ...' should list packages in all active modules and the standard
library.
#
# 'go list [Link]/m/...' should list packages in all modules that begin with
'[Link]/m/'.
#
# 'go list ./...' should list only packages in the current module, not other active
modules.
#
# Warnings about unmatched patterns should only be printed once.
#
# And the go command should be able to keep track of all this!
go list -f '{{.ImportPath}}: {{.Match}}' all ... [Link]/m/... ./... ./xyz...
stdout '[Link]/m/useunicode: \[all \.\.\. [Link]/m/... ./...\]'
stdout '[Link]/m/useunsafe: \[all \.\.\. [Link]/m/... ./...\]'
[cgo] stdout '[Link]/m/useC: \[all \.\.\. [Link]/m/... ./...\]'
[!cgo] ! stdout [Link]/m/useC
stdout '[Link]/unused/useerrors: \[\.\.\.\]' # but not "all"
stdout '[Link]/m/nested/useencoding: \[\.\.\. [Link]/m/...\]' # but NOT
"all" or "./..."
stdout '^unicode: \[all \.\.\.\]'
stdout '^unsafe: \[all \.\.\.\]'
stdout 'index/suffixarray: \[\.\.\.\]'
stdout 'cmd/pprof: \[\.\.\.\]'
stderr -count=1 '^go: warning: "./xyz..." matched no packages$'
# 'go list ./...' should not try to resolve the main module.
cd ../empty
go list -deps ./...
! stdout .
! stderr 'finding'
stderr -count=1 '^go: warning: "./..." matched no packages'
# disabling cgo should drop useC
[short] skip
env CGO_ENABLED=0
go list -f '{{.ImportPath}}: {{.Match}}' all ... [Link]/m/... ./... ./xyz...
! stdout [Link]/m/useC
-- m/[Link] --
module [Link]/m
require [Link]/unused v0.0.0 // indirect
replace [Link]/unused => ../unused
require [Link]/m/nested v0.0.0 // indirect
replace [Link]/m/nested => ../nested
-- m/useC/[Link] --
package useC
import _ "C" // "C" is a pseudo-package, not an actual one
-- m/useunicode/[Link] --
package useunicode
import _ "unicode"
-- m/useunsafe/[Link] --
package useunsafe
import _ "unsafe"
-- unused/[Link] --
module [Link]/unused
-- unused/useerrors/[Link] --
package useerrors
import _ "errors"
-- nested/[Link] --
module [Link]/m/nested
-- nested/useencoding/[Link] --
package useencoding
import _ "encoding"
-- empty/[Link] --
module [Link]/empty