@@ -192,20 +192,10 @@ func findGoModFiles(root string) []string {
192
192
return util .FindAllFilesWithName (root , "go.mod" , util .SkipVendorChecks ... )
193
193
}
194
194
195
- // A regular expression for the Go toolchain version syntax.
196
- var toolchainVersionRe * regexp.Regexp = regexp .MustCompile (`(?m)^([0-9]+\.[0-9]+(\.[0-9]+|rc[0-9]+))$` )
197
-
198
- // Returns true if the `go.mod` file specifies a Go language version, that version is `1.21` or greater, and
199
- // there is no `toolchain` directive, and the Go language version is not a valid toolchain version.
200
- func hasInvalidToolchainVersion (modFile * modfile.File ) bool {
201
- return modFile .Toolchain == nil && modFile .Go != nil &&
202
- ! toolchainVersionRe .Match ([]byte (modFile .Go .Version )) && util .NewSemVer (modFile .Go .Version ).IsAtLeast (toolchain .V1_21 )
203
- }
204
-
205
195
// Given a list of `go.mod` file paths, try to parse them all. The resulting array of `GoModule` objects
206
196
// will be the same length as the input array and the objects will contain at least the `go.mod` path.
207
197
// If parsing the corresponding file is successful, then the parsed contents will also be available.
208
- func LoadGoModules (emitDiagnostics bool , goModFilePaths []string ) []* GoModule {
198
+ func LoadGoModules (goModFilePaths []string ) []* GoModule {
209
199
results := make ([]* GoModule , len (goModFilePaths ))
210
200
211
201
for i , goModFilePath := range goModFilePaths {
@@ -227,14 +217,6 @@ func LoadGoModules(emitDiagnostics bool, goModFilePaths []string) []*GoModule {
227
217
}
228
218
229
219
results [i ].Module = modFile
230
-
231
- // If this `go.mod` file specifies a Go language version, that version is `1.21` or greater, and
232
- // there is no `toolchain` directive, check that it is a valid Go toolchain version. Otherwise,
233
- // `go` commands which try to download the right version of the Go toolchain will fail. We detect
234
- // this situation and emit a diagnostic.
235
- if hasInvalidToolchainVersion (modFile ) {
236
- diagnostics .EmitInvalidToolchainVersion (goModFilePath , modFile .Go .Version )
237
- }
238
220
}
239
221
240
222
return results
@@ -243,7 +225,7 @@ func LoadGoModules(emitDiagnostics bool, goModFilePaths []string) []*GoModule {
243
225
// Given a path to a `go.work` file, this function attempts to parse the `go.work` file. If unsuccessful,
244
226
// we attempt to discover `go.mod` files within subdirectories of the directory containing the `go.work`
245
227
// file ourselves.
246
- func discoverWorkspace (emitDiagnostics bool , workFilePath string ) GoWorkspace {
228
+ func discoverWorkspace (workFilePath string ) GoWorkspace {
247
229
log .Printf ("Loading %s...\n " , workFilePath )
248
230
baseDir := filepath .Dir (workFilePath )
249
231
workFileSrc , err := os .ReadFile (workFilePath )
@@ -257,7 +239,7 @@ func discoverWorkspace(emitDiagnostics bool, workFilePath string) GoWorkspace {
257
239
258
240
return GoWorkspace {
259
241
BaseDir : baseDir ,
260
- Modules : LoadGoModules (emitDiagnostics , goModFilePaths ),
242
+ Modules : LoadGoModules (goModFilePaths ),
261
243
DepMode : GoGetWithModules ,
262
244
ModMode : getModMode (GoGetWithModules , baseDir ),
263
245
}
@@ -274,7 +256,7 @@ func discoverWorkspace(emitDiagnostics bool, workFilePath string) GoWorkspace {
274
256
275
257
return GoWorkspace {
276
258
BaseDir : baseDir ,
277
- Modules : LoadGoModules (emitDiagnostics , goModFilePaths ),
259
+ Modules : LoadGoModules (goModFilePaths ),
278
260
DepMode : GoGetWithModules ,
279
261
ModMode : getModMode (GoGetWithModules , baseDir ),
280
262
}
@@ -297,7 +279,7 @@ func discoverWorkspace(emitDiagnostics bool, workFilePath string) GoWorkspace {
297
279
return GoWorkspace {
298
280
BaseDir : baseDir ,
299
281
WorkspaceFile : workFile ,
300
- Modules : LoadGoModules (emitDiagnostics , goModFilePaths ),
282
+ Modules : LoadGoModules (goModFilePaths ),
301
283
DepMode : GoGetWithModules ,
302
284
ModMode : ModReadonly , // Workspaces only support "readonly"
303
285
}
@@ -325,7 +307,7 @@ func discoverWorkspaces(emitDiagnostics bool) []GoWorkspace {
325
307
for i , goModFile := range goModFiles {
326
308
results [i ] = GoWorkspace {
327
309
BaseDir : filepath .Dir (goModFile ),
328
- Modules : LoadGoModules (emitDiagnostics , []string {goModFile }),
310
+ Modules : LoadGoModules ([]string {goModFile }),
329
311
DepMode : GoGetWithModules ,
330
312
ModMode : getModMode (GoGetWithModules , filepath .Dir (goModFile )),
331
313
}
@@ -342,7 +324,7 @@ func discoverWorkspaces(emitDiagnostics bool) []GoWorkspace {
342
324
343
325
results := make ([]GoWorkspace , len (goWorkFiles ))
344
326
for i , workFilePath := range goWorkFiles {
345
- results [i ] = discoverWorkspace (emitDiagnostics , workFilePath )
327
+ results [i ] = discoverWorkspace (workFilePath )
346
328
}
347
329
348
330
// Add all stray `go.mod` files (i.e. those not referenced by `go.work` files)
@@ -374,7 +356,7 @@ func discoverWorkspaces(emitDiagnostics bool) []GoWorkspace {
374
356
log .Printf ("Module %s is not referenced by any go.work file; adding it separately.\n " , goModFile )
375
357
results = append (results , GoWorkspace {
376
358
BaseDir : filepath .Dir (goModFile ),
377
- Modules : LoadGoModules (emitDiagnostics , []string {goModFile }),
359
+ Modules : LoadGoModules ([]string {goModFile }),
378
360
DepMode : GoGetWithModules ,
379
361
ModMode : getModMode (GoGetWithModules , filepath .Dir (goModFile )),
380
362
})
0 commit comments