@@ -134,35 +134,54 @@ <h2 id="tools">Tools</h2>
134
134
135
135
< h3 id ="go-command "> Go command</ h3 >
136
136
137
- < h4 id ="lazy-loading "> Lazy module loading</ h4 >
137
+ < a id ="lazy-loading "> <!-- for existing links only --> </ a >
138
+ < h4 id ="graph-pruning "> Pruned module graphs in < code > go 1.17</ code > modules</ h4 >
138
139
139
140
< p > <!-- golang.org/issue/36460 -->
141
+ If a module specifies < code > go</ code > < code > 1.17</ code > or higher, the module
142
+ graph includes only the < em > immediate</ em > dependencies of
143
+ other < code > go</ code > < code > 1.17</ code > modules, not their full transitive
144
+ dependencies. (See < a href ="/ref/mod#graph-pruning "> Module graph pruning</ a >
145
+ for more detail.)
146
+ </ p >
147
+
148
+ < p >
149
+ For the < code > go</ code > command to correctly resolve transitive imports using
150
+ the pruned module graph, the < code > go.mod</ code > file for each module needs to
151
+ include more detail about the transitive dependencies relevant to that module.
140
152
If a module specifies < code > go</ code > < code > 1.17</ code > or higher in its
141
- < code > go.mod</ code > file, its transitive requirements are now loaded lazily,
142
- avoiding the need to download or read < code > go.mod</ code > files for
143
- otherwise-irrelevant dependencies. To support lazy loading, in Go 1.17 modules
144
- the < code > go</ code > command maintains < em > explicit</ em > requirements in
145
- the < code > go.mod</ code > file for every dependency that provides any package
146
- transitively imported by any package or test within the module.
147
- See < a href ="https://golang.org/design/36460-lazy-module-loading "> the design
148
- document</ a > for more detail.
149
- <!-- TODO(bcmills): replace the design-doc link with proper documentation. -->
153
+ < code > go.mod</ code > file, its < codeg > go.mod</ code > file now contains an
154
+ explicit < a href ="/ref/mod#go-mod-file-require "> < code > require</ code >
155
+ directive</ a > for every module that provides a transitively-imported package.
156
+ (In previous versions, the < code > go.mod</ code > file typically only included
157
+ explicit requirements for < em > directly</ em > -imported packages.)
158
+ < p >
159
+
160
+ < p >
161
+ Since the expanded < code > go.mod</ code > file needed for module graph pruning
162
+ includes all of the dependencies needed to load the imports of any package in
163
+ the main module, if the main module specifies
164
+ < code > go</ code > < code > 1.17</ code > or higher the < code > go</ code > tool no longer
165
+ reads (or even downloads) < code > go.mod</ code > files for dependencies if they
166
+ are not needed in order to complete the requested command.
167
+ (See < a href ="/ref/mod#lazy-loading "> Lazy loading</ a > .)
150
168
</ p >
151
169
152
170
< p > <!-- golang.org/issue/45965 -->
153
- Because the number of additional explicit requirements in the go.mod file may
154
- be substantial, in a Go 1.17 module the newly-added requirements
155
- on < em > indirect</ em > dependencies are maintained in a
156
- separate < code > require</ code > block from the block containing direct
157
- dependencies.
171
+ Because the number of explicit requirements may be substantially larger in an
172
+ expanded Go 1.17 < code > go.mod </ code > file, the newly-added requirements
173
+ on < em > indirect</ em > dependencies in a < code > go </ code > < code > 1.17 </ code >
174
+ module are maintained in a separate < code > require</ code > block from the block
175
+ containing direct dependencies.
158
176
</ p >
159
177
160
178
< p > <!-- golang.org/issue/45094 -->
161
- To facilitate the upgrade to lazy loading, the
162
- < code > go</ code > < code > mod</ code > < code > tidy</ code > subcommand now supports
163
- a < code > -go</ code > flag to set or change the < code > go</ code > version in
164
- the < code > go.mod</ code > file. To enable lazy loading for an existing module
165
- without changing the selected versions of its dependencies, run:
179
+ To facilitate the upgrade to Go 1.17 pruned module graphs, the
180
+ < a href ="/ref/mod#go-mod-tidy "> < code > go</ code > < code > mod</ code > < code > tidy</ code > </ a >
181
+ subcommand now supports a < code > -go</ code > flag to set or change
182
+ the < code > go</ code > version in the < code > go.mod</ code > file. To convert
183
+ the < code > go.mod</ code > file for an existing module to Go 1.17 without
184
+ changing the selected versions of its dependencies, run:
166
185
</ p >
167
186
168
187
< pre >
@@ -199,10 +218,10 @@ <h4 id="lazy-loading">Lazy module loading</h4>
199
218
</ p >
200
219
201
220
< p > <!-- golang.org/issue/46366 -->
202
- The < code > go</ code > < code > mod</ code > < code > graph</ code > subcommand also
203
- supports the < code > -go</ code > flag, which causes it to report the graph as
204
- seen by the indicated Go version, showing dependencies that may otherwise be
205
- pruned out by lazy loading .
221
+ The < a href =" /ref/mod#go-mod-graph " > < code > go</ code > < code > mod</ code > < code > graph</ code > </ a >
222
+ subcommand also supports the < code > -go</ code > flag, which causes it to report
223
+ the graph as seen by the indicated Go version, showing dependencies that may
224
+ otherwise be pruned out .
206
225
</ p >
207
226
208
227
< h4 id ="module-deprecation-comments "> Module deprecation comments</ h4 >
@@ -270,7 +289,8 @@ <h4 id="vendor"><code>vendor</code> contents</h4>
270
289
271
290
< p > <!-- golang.org/issue/36876 -->
272
291
If the main module specifies < code > go</ code > < code > 1.17</ code > or higher,
273
- < code > go</ code > < code > mod</ code > < code > vendor</ code > now annotates
292
+ < a href ="/ref/mod#go-mod-vendor "> < code > go</ code > < code > mod</ code > < code > vendor</ code > </ a >
293
+ now annotates
274
294
< code > vendor/modules.txt</ code > with the < code > go</ code > version indicated by
275
295
each vendored module in its own < code > go.mod</ code > file. The annotated
276
296
version is used when building the module's packages from vendored source code.
0 commit comments