@@ -192,20 +192,10 @@ func findGoModFiles(root string) []string {
192192 return util .FindAllFilesWithName (root , "go.mod" , util .SkipVendorChecks ... )
193193}
194194
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-
205195// Given a list of `go.mod` file paths, try to parse them all. The resulting array of `GoModule` objects
206196// will be the same length as the input array and the objects will contain at least the `go.mod` path.
207197// 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 {
209199 results := make ([]* GoModule , len (goModFilePaths ))
210200
211201 for i , goModFilePath := range goModFilePaths {
@@ -227,14 +217,6 @@ func LoadGoModules(emitDiagnostics bool, goModFilePaths []string) []*GoModule {
227217 }
228218
229219 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- }
238220 }
239221
240222 return results
@@ -243,7 +225,7 @@ func LoadGoModules(emitDiagnostics bool, goModFilePaths []string) []*GoModule {
243225// Given a path to a `go.work` file, this function attempts to parse the `go.work` file. If unsuccessful,
244226// we attempt to discover `go.mod` files within subdirectories of the directory containing the `go.work`
245227// file ourselves.
246- func discoverWorkspace (emitDiagnostics bool , workFilePath string ) GoWorkspace {
228+ func discoverWorkspace (workFilePath string ) GoWorkspace {
247229 log .Printf ("Loading %s...\n " , workFilePath )
248230 baseDir := filepath .Dir (workFilePath )
249231 workFileSrc , err := os .ReadFile (workFilePath )
@@ -257,7 +239,7 @@ func discoverWorkspace(emitDiagnostics bool, workFilePath string) GoWorkspace {
257239
258240 return GoWorkspace {
259241 BaseDir : baseDir ,
260- Modules : LoadGoModules (emitDiagnostics , goModFilePaths ),
242+ Modules : LoadGoModules (goModFilePaths ),
261243 DepMode : GoGetWithModules ,
262244 ModMode : getModMode (GoGetWithModules , baseDir ),
263245 }
@@ -274,7 +256,7 @@ func discoverWorkspace(emitDiagnostics bool, workFilePath string) GoWorkspace {
274256
275257 return GoWorkspace {
276258 BaseDir : baseDir ,
277- Modules : LoadGoModules (emitDiagnostics , goModFilePaths ),
259+ Modules : LoadGoModules (goModFilePaths ),
278260 DepMode : GoGetWithModules ,
279261 ModMode : getModMode (GoGetWithModules , baseDir ),
280262 }
@@ -297,7 +279,7 @@ func discoverWorkspace(emitDiagnostics bool, workFilePath string) GoWorkspace {
297279 return GoWorkspace {
298280 BaseDir : baseDir ,
299281 WorkspaceFile : workFile ,
300- Modules : LoadGoModules (emitDiagnostics , goModFilePaths ),
282+ Modules : LoadGoModules (goModFilePaths ),
301283 DepMode : GoGetWithModules ,
302284 ModMode : ModReadonly , // Workspaces only support "readonly"
303285 }
@@ -325,7 +307,7 @@ func discoverWorkspaces(emitDiagnostics bool) []GoWorkspace {
325307 for i , goModFile := range goModFiles {
326308 results [i ] = GoWorkspace {
327309 BaseDir : filepath .Dir (goModFile ),
328- Modules : LoadGoModules (emitDiagnostics , []string {goModFile }),
310+ Modules : LoadGoModules ([]string {goModFile }),
329311 DepMode : GoGetWithModules ,
330312 ModMode : getModMode (GoGetWithModules , filepath .Dir (goModFile )),
331313 }
@@ -342,7 +324,7 @@ func discoverWorkspaces(emitDiagnostics bool) []GoWorkspace {
342324
343325 results := make ([]GoWorkspace , len (goWorkFiles ))
344326 for i , workFilePath := range goWorkFiles {
345- results [i ] = discoverWorkspace (emitDiagnostics , workFilePath )
327+ results [i ] = discoverWorkspace (workFilePath )
346328 }
347329
348330 // Add all stray `go.mod` files (i.e. those not referenced by `go.work` files)
@@ -374,7 +356,7 @@ func discoverWorkspaces(emitDiagnostics bool) []GoWorkspace {
374356 log .Printf ("Module %s is not referenced by any go.work file; adding it separately.\n " , goModFile )
375357 results = append (results , GoWorkspace {
376358 BaseDir : filepath .Dir (goModFile ),
377- Modules : LoadGoModules (emitDiagnostics , []string {goModFile }),
359+ Modules : LoadGoModules ([]string {goModFile }),
378360 DepMode : GoGetWithModules ,
379361 ModMode : getModMode (GoGetWithModules , filepath .Dir (goModFile )),
380362 })
0 commit comments