aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/go/testdata/script/mod_why.txt
blob: c0ff4647a756f3f0f66c985fac14ef8a1c2e3c8a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
env GO111MODULE=on
[short] skip

# Populate go.sum.
go mod tidy

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