Skip to content

Commit 362b154

Browse files
committed
Separate maxGoVersion into max supported and max to install
1 parent bbd02b8 commit 362b154

File tree

2 files changed

+25
-20
lines changed

2 files changed

+25
-20
lines changed

go/extractor/autobuilder/build-environment.go

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,13 @@ import (
1212
)
1313

1414
var minGoVersion = util.NewSemVer("1.11")
15+
16+
// This can be increased before a new minor version has been released, based on testing with the release candidates.
1517
var maxGoVersion = util.NewSemVer("1.26")
1618

19+
// This should be the maximum supported version which has been released.
20+
var goVersionToInstall = util.NewSemVer("1.26")
21+
1722
type versionInfo struct {
1823
goModVersion util.SemVer // The version of Go found in the go directive in the `go.mod` file.
1924
goEnvVersion util.SemVer // The version of Go found in the environment.
@@ -52,18 +57,18 @@ func getVersionWhenGoModVersionNotFound(v versionInfo) (msg string, version util
5257
// was intended to be used to build this project. Go versions are generally backwards
5358
// compatible, so we install the maximum supported version.
5459
msg = "No version of Go installed and no `go.mod` file found. Requesting the maximum " +
55-
"supported version of Go (" + maxGoVersion.String() + ")."
56-
version = maxGoVersion
60+
"supported version of Go that has been released (" + goVersionToInstall.String() + ")."
61+
version = goVersionToInstall
5762
diagnostics.EmitNoGoModAndNoGoEnv(msg)
5863
} else if outsideSupportedRange(v.goEnvVersion) {
5964
// The Go version installed in the environment is not supported. We have no indication
6065
// which version was intended to be used to build this project. Go versions are generally
6166
// backwards compatible, so we install the maximum supported version.
6267
msg = "No `go.mod` file found. The version of Go installed in the environment (" +
6368
v.goEnvVersion.String() + ") is outside of the supported range (" + minGoVersion.String() + "-" +
64-
maxGoVersion.String() + "). Requesting the maximum supported version of Go (" + maxGoVersion.String() +
65-
")."
66-
version = maxGoVersion
69+
maxGoVersion.String() + "). Requesting the maximum supported version of Go that has " +
70+
"been released (" + goVersionToInstall.String() + ")."
71+
version = goVersionToInstall
6772
diagnostics.EmitNoGoModAndGoEnvUnsupported(msg)
6873
} else {
6974
// 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.
8691
// installed. We install the maximum supported version as a best effort.
8792
msg = "The version of Go found in the `go.mod` file (" + v.goModVersion.String() +
8893
") is above the supported range (" + minGoVersion.String() + "-" + maxGoVersion.String() +
89-
"). No version of Go installed. Requesting the maximum supported version of Go (" +
90-
maxGoVersion.String() + ")."
91-
version = maxGoVersion
94+
"). No version of Go installed. Requesting the maximum supported version of Go that has " +
95+
"been released (" + goVersionToInstall.String() + ")."
96+
version = goVersionToInstall
9297
diagnostics.EmitGoModVersionTooHighAndNoGoEnv(msg)
9398
} else if aboveSupportedRange(v.goEnvVersion) {
9499
// 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.
108113
") is above the supported range (" + minGoVersion.String() + "-" + maxGoVersion.String() +
109114
"). The version of Go installed in the environment (" + v.goEnvVersion.String() +
110115
") is below the supported range (" + minGoVersion.String() + "-" + maxGoVersion.String() +
111-
"). Requesting the maximum supported version of Go (" + maxGoVersion.String() + ")."
112-
version = maxGoVersion
116+
"). Requesting the maximum supported version of Go that has been released (" + goVersionToInstall.String() + ")."
117+
version = goVersionToInstall
113118
diagnostics.EmitGoModVersionTooHighAndEnvVersionTooLow(msg)
114119
} else if maxGoVersion.IsNewerThan(v.goEnvVersion) {
115120
// 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.
119124
") is above the supported range (" + minGoVersion.String() + "-" + maxGoVersion.String() +
120125
"). The version of Go installed in the environment (" + v.goEnvVersion.String() +
121126
") is below the maximum supported version (" + maxGoVersion.String() +
122-
"). Requesting the maximum supported version of Go (" + maxGoVersion.String() + ")."
123-
version = maxGoVersion
127+
"). Requesting the maximum supported version of Go that has been released (" + goVersionToInstall.String() + ")."
128+
version = goVersionToInstall
124129
diagnostics.EmitGoModVersionTooHighAndEnvVersionBelowMax(msg)
125130
} else {
126131
// The version in the `go.mod` file is above the supported range. The version of Go that

go/extractor/autobuilder/build-environment_test.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,18 @@ func TestGetVersionToInstall(t *testing.T) {
1313
}
1414
tests := map[inputVersions]string{
1515
// getVersionWhenGoModVersionNotFound()
16-
{"", ""}: maxGoVersion.String(),
17-
{"", "1.2.2"}: maxGoVersion.String(),
18-
{"", "9999.0.1"}: maxGoVersion.String(),
16+
{"", ""}: goVersionToInstall.String(),
17+
{"", "1.2.2"}: goVersionToInstall.String(),
18+
{"", "9999.0.1"}: goVersionToInstall.String(),
1919
{"", "1.11.13"}: "",
2020
{"", "1.20.3"}: "",
2121

2222
// getVersionWhenGoModVersionTooHigh()
23-
{"9999.0", ""}: maxGoVersion.String(),
24-
{"9999.0", "9999.0.1"}: "",
25-
{"9999.0", "1.1"}: maxGoVersion.String(),
26-
{"9999.0", minGoVersion.String()}: maxGoVersion.String(),
27-
{"9999.0", maxGoVersion.String()}: "",
23+
{"9999.0", ""}: goVersionToInstall.String(),
24+
{"9999.0", "9999.0.1"}: "",
25+
{"9999.0", "1.1"}: goVersionToInstall.String(),
26+
{"9999.0", minGoVersion.String()}: goVersionToInstall.String(),
27+
{"9999.0", goVersionToInstall.String()}: "",
2828

2929
// getVersionWhenGoModVersionTooLow()
3030
{"0.0", ""}: minGoVersion.String(),

0 commit comments

Comments
 (0)