@@ -731,18 +731,27 @@ func outsideSupportedRange(version string) bool {
731731// or the empty string if we should not attempt to install a version of Go.
732732func checkForGoModVersionNotFound (v versionInfo ) (msg , version string ) {
733733 if ! v .goEnvVersionFound {
734+ // We definitely need to install a version. We have no indication which version was
735+ // intended to be used to build this project. Go versions are generally backwards
736+ // compatible, so we install the maximum supported version.
734737 msg = "No version of Go installed and no `go.mod` file found. Writing an environment " +
735738 "file specifying the maximum supported version of Go (" + maxGoVersion + ")."
736739 version = maxGoVersion
737740 diagnostics .EmitNoGoModAndNoGoEnv (msg )
738741 } else if outsideSupportedRange (v .goEnvVersion ) {
742+ // We definitely need to install a version. We have no indication which version was
743+ // intended to be used to build this project. Go versions are generally backwards
744+ // compatible, so we install the maximum supported version.
739745 msg = "No `go.mod` file found. The version of Go installed in the environment (" +
740746 v .goEnvVersion + ") is outside of the supported range (" + minGoVersion + "-" +
741747 maxGoVersion + "). Writing an environment file specifying the maximum supported " +
742748 "version of Go (" + maxGoVersion + ")."
743749 version = maxGoVersion
744750 diagnostics .EmitNoGoModAndGoEnvUnsupported (msg )
745751 } else {
752+ // The version of Go that is installed is supported. We have no indication which version
753+ // was intended to be used to build this project. We assume that the installed version is
754+ // suitable and do not install a version of Go.
746755 msg = "No `go.mod` file found. Version " + v .goEnvVersion + " installed in the " +
747756 "environment is supported. Writing an environment file not specifying any " +
748757 "version of Go."
@@ -757,31 +766,43 @@ func checkForGoModVersionNotFound(v versionInfo) (msg, version string) {
757766// or the empty string if we should not attempt to install a version of Go.
758767func checkForGoModVersionFound (v versionInfo ) (msg , version string ) {
759768 if outsideSupportedRange (v .goModVersion ) {
769+ // The project is intended to be built with a version of Go that is not supported.
770+ // We do not install a version of Go.
760771 msg = "The version of Go found in the `go.mod` file (" + v .goModVersion +
761772 ") is outside of the supported range (" + minGoVersion + "-" + maxGoVersion +
762773 "). Writing an environment file not specifying any version of Go."
763774 version = ""
764775 diagnostics .EmitUnsupportedVersionGoMod (msg )
765776 } else if ! v .goEnvVersionFound {
777+ // There is no Go version installed. The version in the `go.mod` file is supported.
778+ // We install the version from the `go.mod` file.
766779 msg = "No version of Go installed. Writing an environment file specifying the version " +
767780 "of Go found in the `go.mod` file (" + v .goModVersion + ")."
768781 version = v .goModVersion
769782 diagnostics .EmitNoGoEnv (msg )
770783 } else if outsideSupportedRange (v .goEnvVersion ) {
784+ // The version of Go that is installed is outside of the supported range. The version in
785+ // the `go.mod` file is supported. We install the version from the `go.mod` file.
771786 msg = "The version of Go installed in the environment (" + v .goEnvVersion +
772787 ") is outside of the supported range (" + minGoVersion + "-" + maxGoVersion + "). " +
773788 "Writing an environment file specifying the version of Go from the `go.mod` file (" +
774789 v .goModVersion + ")."
775790 version = v .goModVersion
776791 diagnostics .EmitVersionGoModSupportedAndGoEnvUnsupported (msg )
777792 } else if semver .Compare ("v" + v .goModVersion , "v" + v .goEnvVersion ) > 0 {
793+ // The version of Go that is installed is supported. The version in the `go.mod` file is
794+ // supported and is higher than the version that is installed. We install the version from
795+ // the `go.mod` file.
778796 msg = "The version of Go installed in the environment (" + v .goEnvVersion +
779797 ") is lower than the version found in the `go.mod` file (" + v .goModVersion +
780798 "). Writing an environment file specifying the version of Go from the `go.mod` " +
781799 "file (" + v .goModVersion + ")."
782800 version = v .goModVersion
783801 diagnostics .EmitVersionGoModHigherVersionEnvironment (msg )
784802 } else {
803+ // The version of Go that is installed is supported. The version in the `go.mod` file is
804+ // supported and is lower than or equal to the version that is installed. We do not install
805+ // a version of Go.
785806 msg = "The version of Go installed in the environment (" + v .goEnvVersion +
786807 ") is supported and is high enough for the version found in the `go.mod` file (" +
787808 v .goModVersion + "). Writing an environment file not specifying any version of Go."
0 commit comments