Skip to content

Commit 5b56053

Browse files
author
Bryan C. Mills
committed
cmd/go: test package patterns with multiple modules
This change replaces https://golang.org/cl/125835. Updates #26317. Change-Id: I38ae1f93e5f5c86737a4b489df498c18b179781d Reviewed-on: https://go-review.googlesource.com/128637 Reviewed-by: Russ Cox <[email protected]>
1 parent 261609f commit 5b56053

File tree

1 file changed

+77
-0
lines changed

1 file changed

+77
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
env GO111MODULE=on
2+
3+
cd m
4+
5+
# 'go list all' should list all of the packages used (directly or indirectly) by
6+
# the packages in the main module, but no other packages from the standard
7+
# library or active modules.
8+
go list all
9+
cmp stdout all.txt
10+
11+
# 'go list ...' should list packages in all active modules and the standard library.
12+
# BUG: It currently omits the standard library (https://golang.org/issue/26905).
13+
go list ...
14+
cmp stdout dots.txt
15+
16+
# 'go list example.com/m/...' should list packages in all modules that begin with
17+
# "example.com/m/".
18+
go list example.com/m/...
19+
cmp stdout prefix.txt
20+
21+
# 'go list ./...' should list only packages in the current module, not other active modules.
22+
go list ./...
23+
cmp stdout in-mod.txt
24+
25+
26+
-- m/go.mod --
27+
module example.com/m
28+
29+
require example.com/unused v0.0.0 // indirect
30+
replace example.com/unused => ../unused
31+
32+
require example.com/m/nested v0.0.0 // indirect
33+
replace example.com/m/nested => ../nested
34+
35+
-- m/useC/useC.go --
36+
package useC
37+
import _ "C" // "C" is a pseudo-package, not an actual one
38+
-- m/useunicode/useunicode.go --
39+
package useunicode
40+
import _ "unicode"
41+
-- m/useunsafe/useunsafe.go --
42+
package useunsafe
43+
import _ "unsafe"
44+
45+
-- unused/go.mod --
46+
module example.com/unused
47+
-- unused/useerrors/useerrors.go --
48+
package useerrors
49+
import _ "errors"
50+
51+
-- nested/go.mod --
52+
module example.com/m/nested
53+
-- nested/useencoding/useencoding.go --
54+
package useencoding
55+
import _ "encoding"
56+
57+
-- m/all.txt --
58+
example.com/m/useC
59+
example.com/m/useunicode
60+
example.com/m/useunsafe
61+
unicode
62+
unsafe
63+
-- m/dots.txt --
64+
example.com/m/useC
65+
example.com/m/useunicode
66+
example.com/m/useunsafe
67+
example.com/m/nested/useencoding
68+
example.com/unused/useerrors
69+
-- m/prefix.txt --
70+
example.com/m/useC
71+
example.com/m/useunicode
72+
example.com/m/useunsafe
73+
example.com/m/nested/useencoding
74+
-- m/in-mod.txt --
75+
example.com/m/useC
76+
example.com/m/useunicode
77+
example.com/m/useunsafe

0 commit comments

Comments
 (0)