summaryrefslogtreecommitdiffstats
path: root/src/cmd/go/testdata/script/mod_why.txt
blob: b3036fa83040c0b1c69623041c93086547fb3caf (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
119
120
121
122
123
124
125
126
127
128
129
130
env GO111MODULE=on
[short] skip

# Populate go.sum.
go mod tidy
cp go.mod go.mod.orig

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 a test of a dependency?
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

# package in a module that isn't even in the module graph
# (https://golang.org/issue/26977)
go mod why rsc.io/fortune
cmp stdout why-missing.txt

# None of these command should have changed the go.mod file.
cmp go.mod go.mod.orig

-- 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
-- why-missing.txt --
# rsc.io/fortune
(main module does not need package rsc.io/fortune)