@@ -731,18 +731,27 @@ func outsideSupportedRange(version string) bool {
731
731
// or the empty string if we should not attempt to install a version of Go.
732
732
func checkForGoModVersionNotFound (v versionInfo ) (msg , version string ) {
733
733
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.
734
737
msg = "No version of Go installed and no `go.mod` file found. Writing an environment " +
735
738
"file specifying the maximum supported version of Go (" + maxGoVersion + ")."
736
739
version = maxGoVersion
737
740
diagnostics .EmitNoGoModAndNoGoEnv (msg )
738
741
} 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.
739
745
msg = "No `go.mod` file found. The version of Go installed in the environment (" +
740
746
v .goEnvVersion + ") is outside of the supported range (" + minGoVersion + "-" +
741
747
maxGoVersion + "). Writing an environment file specifying the maximum supported " +
742
748
"version of Go (" + maxGoVersion + ")."
743
749
version = maxGoVersion
744
750
diagnostics .EmitNoGoModAndGoEnvUnsupported (msg )
745
751
} 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.
746
755
msg = "No `go.mod` file found. Version " + v .goEnvVersion + " installed in the " +
747
756
"environment is supported. Writing an environment file not specifying any " +
748
757
"version of Go."
@@ -757,31 +766,43 @@ func checkForGoModVersionNotFound(v versionInfo) (msg, version string) {
757
766
// or the empty string if we should not attempt to install a version of Go.
758
767
func checkForGoModVersionFound (v versionInfo ) (msg , version string ) {
759
768
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.
760
771
msg = "The version of Go found in the `go.mod` file (" + v .goModVersion +
761
772
") is outside of the supported range (" + minGoVersion + "-" + maxGoVersion +
762
773
"). Writing an environment file not specifying any version of Go."
763
774
version = ""
764
775
diagnostics .EmitUnsupportedVersionGoMod (msg )
765
776
} 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.
766
779
msg = "No version of Go installed. Writing an environment file specifying the version " +
767
780
"of Go found in the `go.mod` file (" + v .goModVersion + ")."
768
781
version = v .goModVersion
769
782
diagnostics .EmitNoGoEnv (msg )
770
783
} 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.
771
786
msg = "The version of Go installed in the environment (" + v .goEnvVersion +
772
787
") is outside of the supported range (" + minGoVersion + "-" + maxGoVersion + "). " +
773
788
"Writing an environment file specifying the version of Go from the `go.mod` file (" +
774
789
v .goModVersion + ")."
775
790
version = v .goModVersion
776
791
diagnostics .EmitVersionGoModSupportedAndGoEnvUnsupported (msg )
777
792
} 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.
778
796
msg = "The version of Go installed in the environment (" + v .goEnvVersion +
779
797
") is lower than the version found in the `go.mod` file (" + v .goModVersion +
780
798
"). Writing an environment file specifying the version of Go from the `go.mod` " +
781
799
"file (" + v .goModVersion + ")."
782
800
version = v .goModVersion
783
801
diagnostics .EmitVersionGoModHigherVersionEnvironment (msg )
784
802
} 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.
785
806
msg = "The version of Go installed in the environment (" + v .goEnvVersion +
786
807
") is supported and is high enough for the version found in the `go.mod` file (" +
787
808
v .goModVersion + "). Writing an environment file not specifying any version of Go."
0 commit comments