From 362b1543a00e7556da4c5c8f2274e89dd5b68c2d Mon Sep 17 00:00:00 2001 From: Owen Mansel-Chan Date: Wed, 11 Mar 2026 15:51:35 +0000 Subject: [PATCH 1/3] Separate `maxGoVersion` into max supported and max to install --- go/extractor/autobuilder/build-environment.go | 29 +++++++++++-------- .../autobuilder/build-environment_test.go | 16 +++++----- 2 files changed, 25 insertions(+), 20 deletions(-) diff --git a/go/extractor/autobuilder/build-environment.go b/go/extractor/autobuilder/build-environment.go index c660373205b2..d324a690f4f6 100644 --- a/go/extractor/autobuilder/build-environment.go +++ b/go/extractor/autobuilder/build-environment.go @@ -12,8 +12,13 @@ import ( ) var minGoVersion = util.NewSemVer("1.11") + +// This can be increased before a new minor version has been released, based on testing with the release candidates. var maxGoVersion = util.NewSemVer("1.26") +// This should be the maximum supported version which has been released. +var goVersionToInstall = util.NewSemVer("1.26") + type versionInfo struct { goModVersion util.SemVer // The version of Go found in the go directive in the `go.mod` file. goEnvVersion util.SemVer // The version of Go found in the environment. @@ -52,8 +57,8 @@ func getVersionWhenGoModVersionNotFound(v versionInfo) (msg string, version util // was intended to be used to build this project. Go versions are generally backwards // compatible, so we install the maximum supported version. msg = "No version of Go installed and no `go.mod` file found. Requesting the maximum " + - "supported version of Go (" + maxGoVersion.String() + ")." - version = maxGoVersion + "supported version of Go that has been released (" + goVersionToInstall.String() + ")." + version = goVersionToInstall diagnostics.EmitNoGoModAndNoGoEnv(msg) } else if outsideSupportedRange(v.goEnvVersion) { // The Go version installed in the environment is not supported. We have no indication @@ -61,9 +66,9 @@ func getVersionWhenGoModVersionNotFound(v versionInfo) (msg string, version util // backwards compatible, so we install the maximum supported version. msg = "No `go.mod` file found. The version of Go installed in the environment (" + v.goEnvVersion.String() + ") is outside of the supported range (" + minGoVersion.String() + "-" + - maxGoVersion.String() + "). Requesting the maximum supported version of Go (" + maxGoVersion.String() + - ")." - version = maxGoVersion + maxGoVersion.String() + "). Requesting the maximum supported version of Go that has " + + "been released (" + goVersionToInstall.String() + ")." + version = goVersionToInstall diagnostics.EmitNoGoModAndGoEnvUnsupported(msg) } else { // The version of Go that is installed is supported. We have no indication which version @@ -86,9 +91,9 @@ func getVersionWhenGoModVersionTooHigh(v versionInfo) (msg string, version util. // installed. We install the maximum supported version as a best effort. msg = "The version of Go found in the `go.mod` file (" + v.goModVersion.String() + ") is above the supported range (" + minGoVersion.String() + "-" + maxGoVersion.String() + - "). No version of Go installed. Requesting the maximum supported version of Go (" + - maxGoVersion.String() + ")." - version = maxGoVersion + "). No version of Go installed. Requesting the maximum supported version of Go that has " + + "been released (" + goVersionToInstall.String() + ")." + version = goVersionToInstall diagnostics.EmitGoModVersionTooHighAndNoGoEnv(msg) } else if aboveSupportedRange(v.goEnvVersion) { // The version in the `go.mod` file is above the supported range. The version of Go that @@ -108,8 +113,8 @@ func getVersionWhenGoModVersionTooHigh(v versionInfo) (msg string, version util. ") is above the supported range (" + minGoVersion.String() + "-" + maxGoVersion.String() + "). The version of Go installed in the environment (" + v.goEnvVersion.String() + ") is below the supported range (" + minGoVersion.String() + "-" + maxGoVersion.String() + - "). Requesting the maximum supported version of Go (" + maxGoVersion.String() + ")." - version = maxGoVersion + "). Requesting the maximum supported version of Go that has been released (" + goVersionToInstall.String() + ")." + version = goVersionToInstall diagnostics.EmitGoModVersionTooHighAndEnvVersionTooLow(msg) } else if maxGoVersion.IsNewerThan(v.goEnvVersion) { // The version in the `go.mod` file is above the supported range. The version of Go that @@ -119,8 +124,8 @@ func getVersionWhenGoModVersionTooHigh(v versionInfo) (msg string, version util. ") is above the supported range (" + minGoVersion.String() + "-" + maxGoVersion.String() + "). The version of Go installed in the environment (" + v.goEnvVersion.String() + ") is below the maximum supported version (" + maxGoVersion.String() + - "). Requesting the maximum supported version of Go (" + maxGoVersion.String() + ")." - version = maxGoVersion + "). Requesting the maximum supported version of Go that has been released (" + goVersionToInstall.String() + ")." + version = goVersionToInstall diagnostics.EmitGoModVersionTooHighAndEnvVersionBelowMax(msg) } else { // The version in the `go.mod` file is above the supported range. The version of Go that diff --git a/go/extractor/autobuilder/build-environment_test.go b/go/extractor/autobuilder/build-environment_test.go index 382e3aa2914a..a53808a60562 100644 --- a/go/extractor/autobuilder/build-environment_test.go +++ b/go/extractor/autobuilder/build-environment_test.go @@ -13,18 +13,18 @@ func TestGetVersionToInstall(t *testing.T) { } tests := map[inputVersions]string{ // getVersionWhenGoModVersionNotFound() - {"", ""}: maxGoVersion.String(), - {"", "1.2.2"}: maxGoVersion.String(), - {"", "9999.0.1"}: maxGoVersion.String(), + {"", ""}: goVersionToInstall.String(), + {"", "1.2.2"}: goVersionToInstall.String(), + {"", "9999.0.1"}: goVersionToInstall.String(), {"", "1.11.13"}: "", {"", "1.20.3"}: "", // getVersionWhenGoModVersionTooHigh() - {"9999.0", ""}: maxGoVersion.String(), - {"9999.0", "9999.0.1"}: "", - {"9999.0", "1.1"}: maxGoVersion.String(), - {"9999.0", minGoVersion.String()}: maxGoVersion.String(), - {"9999.0", maxGoVersion.String()}: "", + {"9999.0", ""}: goVersionToInstall.String(), + {"9999.0", "9999.0.1"}: "", + {"9999.0", "1.1"}: goVersionToInstall.String(), + {"9999.0", minGoVersion.String()}: goVersionToInstall.String(), + {"9999.0", goVersionToInstall.String()}: "", // getVersionWhenGoModVersionTooLow() {"0.0", ""}: minGoVersion.String(), From 1beffeaf6813cf6152f148cc89dc8989264fe03f Mon Sep 17 00:00:00 2001 From: Owen Mansel-Chan Date: Wed, 11 Mar 2026 16:00:47 +0000 Subject: [PATCH 2/3] Add test --- go/extractor/autobuilder/build-environment_test.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/go/extractor/autobuilder/build-environment_test.go b/go/extractor/autobuilder/build-environment_test.go index a53808a60562..29504b4f4cb9 100644 --- a/go/extractor/autobuilder/build-environment_test.go +++ b/go/extractor/autobuilder/build-environment_test.go @@ -54,3 +54,9 @@ func TestGetVersionToInstall(t *testing.T) { } } } + +func TestMaxGoVersions(t *testing.T) { + if goVersionToInstall.IsNewerThan(maxGoVersion) { + t.Errorf("goVersionToInstall (%s) should not be newer than maxGoVersion (%s).", goVersionToInstall, maxGoVersion) + } +} From 73f268c32c360da4e5a7a796bf0ccf0aa726486d Mon Sep 17 00:00:00 2001 From: Owen Mansel-Chan <62447351+owen-mc@users.noreply.github.com> Date: Fri, 13 Mar 2026 10:38:38 +0000 Subject: [PATCH 3/3] Update comments Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- go/extractor/autobuilder/build-environment.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/go/extractor/autobuilder/build-environment.go b/go/extractor/autobuilder/build-environment.go index d324a690f4f6..2d9c99964dd3 100644 --- a/go/extractor/autobuilder/build-environment.go +++ b/go/extractor/autobuilder/build-environment.go @@ -55,7 +55,7 @@ func getVersionWhenGoModVersionNotFound(v versionInfo) (msg string, version util if v.goEnvVersion == nil { // There is no Go version installed in the environment. We have no indication which version // was intended to be used to build this project. Go versions are generally backwards - // compatible, so we install the maximum supported version. + // compatible, so we install the maximum supported released version. msg = "No version of Go installed and no `go.mod` file found. Requesting the maximum " + "supported version of Go that has been released (" + goVersionToInstall.String() + ")." version = goVersionToInstall @@ -63,7 +63,7 @@ func getVersionWhenGoModVersionNotFound(v versionInfo) (msg string, version util } else if outsideSupportedRange(v.goEnvVersion) { // The Go version installed in the environment is not supported. We have no indication // which version was intended to be used to build this project. Go versions are generally - // backwards compatible, so we install the maximum supported version. + // backwards compatible, so we install the maximum supported released version. msg = "No `go.mod` file found. The version of Go installed in the environment (" + v.goEnvVersion.String() + ") is outside of the supported range (" + minGoVersion.String() + "-" + maxGoVersion.String() + "). Requesting the maximum supported version of Go that has " +