1 # If go.mod has go 1.27 or higher, multiple require blocks should be
2 # consolidated. Even those with comments.
3
4 cp go.mod.127 go.mod
5 go mod tidy
6 cmp go.mod go.mod.127tidy
7
8 # If go.mod has go 1.26, blocks with comments should be preserved.
9 cp go.mod.126 go.mod
10 go mod tidy
11 cmp go.mod go.mod.126tidy
12
13 -- go.mod.127 --
14 module example.com/m
15
16 go 1.27
17
18 require example.com/a v1.0.0
19
20 // Block comment
21 require (
22 example.com/b v1.0.0
23 )
24
25 // Another block comment
26 require (
27 example.com/d v1.0.0 // an inline comment
28 example.com/c v1.0.0 // indirect
29 )
30
31 // A third block comment
32 require (
33 example.com/e v1.0.0 // indirect
34 )
35
36 replace (
37 example.com/a v1.0.0 => ./a
38 example.com/b v1.0.0 => ./b
39 example.com/c v1.0.0 => ./c
40 example.com/d v1.0.0 => ./d
41 example.com/e v1.0.0 => ./e
42 )
43 -- go.mod.127tidy --
44 module example.com/m
45
46 go 1.27
47
48 // Block comment
49 //
50 // Another block comment
51 require (
52 example.com/a v1.0.0
53 example.com/b v1.0.0
54 example.com/d v1.0.0 // an inline comment
55 )
56
57 // A third block comment
58 require (
59 example.com/c v1.0.0 // indirect
60 example.com/e v1.0.0 // indirect
61 )
62
63 replace (
64 example.com/a v1.0.0 => ./a
65 example.com/b v1.0.0 => ./b
66 example.com/c v1.0.0 => ./c
67 example.com/d v1.0.0 => ./d
68 example.com/e v1.0.0 => ./e
69 )
70 -- go.mod.126 --
71 module example.com/m
72
73 go 1.26
74
75 require example.com/a v1.0.0
76
77 // Block comment
78 require (
79 example.com/b v1.0.0
80 example.com/d v1.0.0
81 )
82
83 require example.com/c v1.0.0 // indirect
84
85 replace (
86 example.com/a v1.0.0 => ./a
87 example.com/b v1.0.0 => ./b
88 example.com/c v1.0.0 => ./c
89 example.com/d v1.0.0 => ./d
90 example.com/e v1.0.0 => ./e
91 )
92 -- go.mod.126tidy --
93 module example.com/m
94
95 go 1.26
96
97 require example.com/a v1.0.0
98
99 // Block comment
100 require (
101 example.com/b v1.0.0
102 example.com/d v1.0.0
103 )
104
105 require (
106 example.com/c v1.0.0 // indirect
107 example.com/e v1.0.0 // indirect
108 )
109
110 replace (
111 example.com/a v1.0.0 => ./a
112 example.com/b v1.0.0 => ./b
113 example.com/c v1.0.0 => ./c
114 example.com/d v1.0.0 => ./d
115 example.com/e v1.0.0 => ./e
116 )
117 -- m.go --
118 package m
119 import _ "example.com/a"
120 import _ "example.com/b"
121 import _ "example.com/d"
122
123 -- a/go.mod --
124 module example.com/a
125 go 1.26
126 require example.com/c v1.0.0
127 require example.com/e v1.0.0
128 -- a/a.go --
129 package a
130 import _ "example.com/c"
131 import _ "example.com/e"
132
133 -- b/go.mod --
134 module example.com/b
135 go 1.26
136 -- b/b.go --
137 package b
138
139 -- c/go.mod --
140 module example.com/c
141 go 1.26
142 -- c/c.go --
143 package c
144
145 -- d/go.mod --
146 module example.com/d
147 go 1.26
148 -- d/d.go --
149 package d
150
151 -- e/go.mod --
152 module example.com/e
153 go 1.26
154 -- e/e.go --
155 package e
156
View as plain text