blob: 4d556fc73fff371565dfd02ba4a6326e692bcc33 [file] [log] [blame]
env GO111MODULE=on
go list -test all
stdout rsc.io/quote
stdout golang.org/x/text/language
# why a package?
go mod why golang.org/x/text/language
cmp stdout why-language.txt
# why a module?
go mod why -m golang.org...
cmp stdout why-text-module.txt
# why a package used only in tests?
go mod why rsc.io/testonly
cmp stdout why-testonly.txt
# why a module used only in tests?
go mod why -m rsc.io/testonly
cmp stdout why-testonly.txt
# test package not needed
go mod why golang.org/x/text/unused
cmp stdout why-unused.txt
# vendor doesn't use packages used only in tests.
go mod why -vendor rsc.io/testonly
cmp stdout why-vendor.txt
# vendor doesn't use modules used only in tests.
go mod why -vendor -m rsc.io/testonly
cmp stdout why-vendor-module.txt
# test multiple packages
go mod why golang.org/x/text/language golang.org/x/text/unused
cmp stdout why-both.txt
# test multiple modules
go mod why -m rsc.io/quote rsc.io/sampler
cmp stdout why-both-module.txt
-- go.mod --
module mymodule
require rsc.io/quote v1.5.2
-- x/x.go --
package x
import _ "mymodule/z"
-- y/y.go --
package y
-- y/y_test.go --
package y
import _ "rsc.io/quote"
-- z/z.go --
package z
import _ "mymodule/y"
-- why-language.txt --
# golang.org/x/text/language
mymodule/y
mymodule/y.test
rsc.io/quote
rsc.io/sampler
golang.org/x/text/language
-- why-unused.txt --
# golang.org/x/text/unused
(main module does not need package golang.org/x/text/unused)
-- why-text-module.txt --
# golang.org/x/text
mymodule/y
mymodule/y.test
rsc.io/quote
rsc.io/sampler
golang.org/x/text/language
-- why-testonly.txt --
# rsc.io/testonly
mymodule/y
mymodule/y.test
rsc.io/quote
rsc.io/sampler
rsc.io/sampler.test
rsc.io/testonly
-- why-vendor.txt --
# rsc.io/testonly
(main module does not need to vendor package rsc.io/testonly)
-- why-vendor-module.txt --
# rsc.io/testonly
(main module does not need to vendor module rsc.io/testonly)
-- why-both.txt --
# golang.org/x/text/language
mymodule/y
mymodule/y.test
rsc.io/quote
rsc.io/sampler
golang.org/x/text/language
# golang.org/x/text/unused
(main module does not need package golang.org/x/text/unused)
-- why-both-module.txt --
# rsc.io/quote
mymodule/y
mymodule/y.test
rsc.io/quote
# rsc.io/sampler
mymodule/y
mymodule/y.test
rsc.io/quote
rsc.io/sampler