@@ -574,22 +574,26 @@ func installDependenciesAndBuild() {
574
574
}
575
575
}
576
576
577
+ // Find the greatest version of Go that is required by the workspaces to check it against the version
578
+ // of Go that is installed on the system.
579
+ greatestGoVersion := project .RequiredGoVersion (& workspaces )
580
+
581
+ // This diagnostic is not required if the system Go version is 1.21 or greater, since the
582
+ // Go tooling should install required Go versions as needed.
583
+ if semver .Compare (toolchain .GetEnvGoSemVer (), "v1.21.0" ) < 0 && greatestGoVersion .Found && semver .Compare ("v" + greatestGoVersion .Version , toolchain .GetEnvGoSemVer ()) > 0 {
584
+ diagnostics .EmitNewerGoVersionNeeded (toolchain .GetEnvGoSemVer (), "v" + greatestGoVersion .Version )
585
+ if val , _ := os .LookupEnv ("GITHUB_ACTIONS" ); val == "true" {
586
+ log .Printf (
587
+ "A go.mod file requires version %s of Go, but version %s is installed. Consider adding an actions/setup-go step to your workflow.\n " ,
588
+ "v" + greatestGoVersion .Version ,
589
+ toolchain .GetEnvGoSemVer ())
590
+ }
591
+ }
592
+
577
593
// Attempt to extract all workspaces; we will tolerate individual extraction failures here
578
594
for i , workspace := range workspaces {
579
595
goVersionInfo := workspace .RequiredGoVersion ()
580
596
581
- // This diagnostic is not required if the system Go version is 1.21 or greater, since the
582
- // Go tooling should install required Go versions as needed.
583
- if semver .Compare (toolchain .GetEnvGoSemVer (), "v1.21.0" ) < 0 && goVersionInfo .Found && semver .Compare ("v" + goVersionInfo .Version , toolchain .GetEnvGoSemVer ()) > 0 {
584
- diagnostics .EmitNewerGoVersionNeeded (toolchain .GetEnvGoSemVer (), "v" + goVersionInfo .Version )
585
- if val , _ := os .LookupEnv ("GITHUB_ACTIONS" ); val == "true" {
586
- log .Printf (
587
- "The go.mod file requires version %s of Go, but version %s is installed. Consider adding an actions/setup-go step to your workflow.\n " ,
588
- "v" + goVersionInfo .Version ,
589
- toolchain .GetEnvGoSemVer ())
590
- }
591
- }
592
-
593
597
fixGoVendorIssues (& workspace , goVersionInfo .Found )
594
598
595
599
tryUpdateGoModAndGoSum (workspace )
0 commit comments