@@ -83,55 +83,58 @@ func getVersionWhenGoModVersionNotFound(v versionInfo) (msg string, version util
8383func getVersionWhenGoModVersionTooHigh (v versionInfo ) (msg string , version util.SemVer ) {
8484 if v .goEnvVersion == nil {
8585 // The version in the `go.mod` file is above the supported range. There is no Go version
86- // installed. We install the maximum supported version as a best effort.
86+ // installed. We install the version from the `go.mod` file as a best effort.
8787 msg = "The version of Go found in the `go.mod` file (" + v .goModVersion .String () +
8888 ") 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
89+ "). No version of Go installed. Requesting the version of Go from the `go.mod` file (" +
90+ v . goModVersion .String () + ")."
91+ version = v . goModVersion
9292 diagnostics .EmitGoModVersionTooHighAndNoGoEnv (msg )
93- } else if aboveSupportedRange (v .goEnvVersion ) {
93+ } else if ! outsideSupportedRange (v .goEnvVersion ) {
9494 // The version in the `go.mod` file is above the supported range. The version of Go that
95- // is installed is above the supported range. We do not install a version of Go.
95+ // is installed is in the supported range. We install the version from the `go.mod`
96+ // file as a best effort.
9697 msg = "The version of Go found in the `go.mod` file (" + v .goModVersion .String () +
9798 ") is above the supported range (" + minGoVersion .String () + "-" + maxGoVersion .String () +
9899 "). The version of Go installed in the environment (" + v .goEnvVersion .String () +
99- ") is above the supported range (" + minGoVersion .String () + "-" + maxGoVersion .String () +
100- "). Not requesting any version of Go."
101- version = nil
102- diagnostics .EmitGoModVersionTooHighAndEnvVersionTooHigh (msg )
100+ ") is inside the supported range (" + minGoVersion .String () + "-" + maxGoVersion .String () +
101+ "). Requesting the version of Go from the `go.mod` file (" + v . goModVersion . String () + ") ."
102+ version = v . goModVersion
103+ diagnostics .EmitGoModVersionTooHighAndEnvVersionSupported (msg )
103104 } else if belowSupportedRange (v .goEnvVersion ) {
104105 // The version in the `go.mod` file is above the supported range. The version of Go that
105- // is installed is below the supported range. We install the maximum supported version as
106- // a best effort.
106+ // is installed is below the supported range. We install the version from the `go.mod`
107+ // file as a best effort.
107108 msg = "The version of Go found in the `go.mod` file (" + v .goModVersion .String () +
108109 ") is above the supported range (" + minGoVersion .String () + "-" + maxGoVersion .String () +
109110 "). The version of Go installed in the environment (" + v .goEnvVersion .String () +
110111 ") is below the supported range (" + minGoVersion .String () + "-" + maxGoVersion .String () +
111- "). Requesting the maximum supported version of Go (" + maxGoVersion .String () + ")."
112- version = maxGoVersion
112+ "). Requesting the version of Go from the `go.mod` file (" + v . goModVersion .String () + ")."
113+ version = v . goModVersion
113114 diagnostics .EmitGoModVersionTooHighAndEnvVersionTooLow (msg )
114- } else if maxGoVersion .IsNewerThan (v .goEnvVersion ) {
115+ } else if v . goModVersion .IsNewerThan (v .goEnvVersion ) {
115116 // The version in the `go.mod` file is above the supported range. The version of Go that
116- // is installed is supported and below the maximum supported version . We install the
117- // maximum supported version as a best effort.
117+ // is installed is also above the supported range, but older . We install the version
118+ // from the `go.mod` file as a best effort.
118119 msg = "The version of Go found in the `go.mod` file (" + v .goModVersion .String () +
119120 ") is above the supported range (" + minGoVersion .String () + "-" + maxGoVersion .String () +
120121 "). The version of Go installed in the environment (" + v .goEnvVersion .String () +
121- ") is below the maximum supported version (" + maxGoVersion .String () +
122- "). Requesting the maximum supported version of Go (" + maxGoVersion .String () + ")."
123- version = maxGoVersion
124- diagnostics .EmitGoModVersionTooHighAndEnvVersionBelowMax (msg )
122+ ") is also above the supported range (" + minGoVersion .String () + "-" + maxGoVersion .String () +
123+ ") but older. Requesting the version of Go from the `go.mod` file (" + v .goModVersion .String () +
124+ ")."
125+ version = v .goModVersion
126+ diagnostics .EmitGoModVersionTooHighAndEnvVersionTooHighButOlder (msg )
125127 } else {
126128 // The version in the `go.mod` file is above the supported range. The version of Go that
127- // is installed is the maximum supported version. We do not install a version of Go.
129+ // is installed is also above the supported range, but newer or equal. We do not install
130+ // a version of Go.
128131 msg = "The version of Go found in the `go.mod` file (" + v .goModVersion .String () +
129132 ") is above the supported range (" + minGoVersion .String () + "-" + maxGoVersion .String () +
130133 "). The version of Go installed in the environment (" + v .goEnvVersion .String () +
131- ") is the maximum supported version ( " + maxGoVersion .String () +
134+ ") is also above the supported range (" + minGoVersion . String () + "- " + maxGoVersion .String () +
132135 "). Not requesting any version of Go."
133136 version = nil
134- diagnostics .EmitGoModVersionTooHighAndEnvVersionMax (msg )
137+ diagnostics .EmitGoModVersionTooHighAndEnvTooHigh (msg )
135138 }
136139
137140 return msg , version
@@ -218,17 +221,16 @@ func getVersionWhenGoModVersionSupported(v versionInfo) (msg string, version uti
218221
219222// Check the versions of Go found in the environment and in the `go.mod` file, and return a
220223// version to install. If the version is the empty string then no installation is required.
221- // We never return a version of Go that is outside of the supported range.
222224//
223- // +-----------------------+-----------------------+-----------------------+-----------------------------------------------------+------------------------------------------------+
224- // | Found in go.mod > | *None* | *Below min supported* | *In supported range* | *Above max supported |
225- // | Installed \/ | | | | |
226- // |-----------------------|-----------------------|-----------------------|-----------------------------------------------------|------------------------------------------------|
227- // | *None* | Install max supported | Install min supported | Install version from go.mod | Install max supported |
228- // | *Below min supported* | Install max supported | Install min supported | Install version from go.mod | Install max supported |
229- // | *In supported range* | No action | No action | Install version from go.mod if newer than installed | Install max supported if newer than installed |
230- // | *Above max supported* | Install max supported | Install min supported | Install version from go.mod | No action |
231- // +-----------------------+-----------------------+-----------------------+-----------------------------------------------------+------------------------------------------------+
225+ // +-----------------------+-----------------------+-----------------------+-----------------------------------------------------+----------------------------------------------------- +
226+ // | Found in go.mod > | *None* | *Below min supported* | *In supported range* | *Above max supported |
227+ // | Installed \/ | | | | |
228+ // |-----------------------|-----------------------|-----------------------|-----------------------------------------------------|----------------------------------------------------- |
229+ // | *None* | Install max supported | Install min supported | Install version from go.mod | Install version from go.mod |
230+ // | *Below min supported* | Install max supported | Install min supported | Install version from go.mod | Install version from go.mod |
231+ // | *In supported range* | No action | No action | Install version from go.mod if newer than installed | Install version from go.mod |
232+ // | *Above max supported* | Install max supported | Install min supported | Install version from go.mod | Install version from go.mod if newer than installed |
233+ // +-----------------------+-----------------------+-----------------------+-----------------------------------------------------+----------------------------------------------------- +
232234func getVersionToInstall (v versionInfo ) (msg string , version util.SemVer ) {
233235 if v .goModVersion == nil {
234236 return getVersionWhenGoModVersionNotFound (v )
0 commit comments