Skip to content

Commit c74d634

Browse files
committed
Go: Run go with a valid toolchain version if we have found an invalid one
1 parent 0d527b2 commit c74d634

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

go/extractor/project/project.go

+10
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,16 @@ func LoadGoModules(emitDiagnostics bool, goModFilePaths []string) []*GoModule {
212212
if modFile.Toolchain == nil && modFile.Go != nil &&
213213
!toolchainVersionRe.Match([]byte(modFile.Go.Version)) && semver.Compare("v"+modFile.Go.Version, "v1.21.0") >= 0 {
214214
diagnostics.EmitInvalidToolchainVersion(goModFilePath, modFile.Go.Version)
215+
216+
modPath := filepath.Dir(goModFilePath)
217+
218+
log.Printf(
219+
"`%s` is not a valid toolchain version, trying to install it explicitly using the canonical representation in `%s`.",
220+
modFile.Go.Version,
221+
modPath,
222+
)
223+
224+
toolchain.InstallVersion(modPath, modFile.Go.Version)
215225
}
216226
}
217227

0 commit comments

Comments
 (0)