@@ -737,12 +737,6 @@ func checkForUnsupportedVersions(v versionInfo) (msg, version string) {
737
737
"). Writing an environment file not specifying any version of Go."
738
738
version = ""
739
739
diagnostics .EmitUnsupportedVersionGoMod (msg )
740
- } else if v .goEnvVersionFound && outsideSupportedRange (v .goEnvVersion ) {
741
- msg = "The version of Go installed in the environment (" + v .goEnvVersion +
742
- ") is outside of the supported range (" + minGoVersion + "-" + maxGoVersion +
743
- "). Writing an environment file not specifying any version of Go."
744
- version = ""
745
- diagnostics .EmitUnsupportedVersionEnvironment (msg )
746
740
}
747
741
748
742
return msg , version
@@ -768,10 +762,20 @@ func checkForVersionsNotFound(v versionInfo) (msg, version string) {
768
762
}
769
763
770
764
if v .goEnvVersionFound && ! v .goModVersionFound {
771
- msg = "No `go.mod` file found. Version " + v .goEnvVersion + " installed in the " +
772
- "environment. Writing an environment file not specifying any version of Go."
773
- version = ""
774
- diagnostics .EmitNoGoMod (msg )
765
+ if outsideSupportedRange (v .goEnvVersion ) {
766
+ msg = "No `go.mod` file found. The version of Go installed in the environment (" +
767
+ v .goEnvVersion + ") is outside of the supported range (" + minGoVersion + "-" +
768
+ maxGoVersion + "). Writing an environment file specifying the maximum supported " +
769
+ "version of Go (" + maxGoVersion + ")."
770
+ version = maxGoVersion
771
+ diagnostics .EmitNoGoModAndGoEnvUnsupported (msg )
772
+ } else {
773
+ msg = "No `go.mod` file found. Version " + v .goEnvVersion + " installed in the " +
774
+ "environment is supported. Writing an environment file not specifying any " +
775
+ "version of Go."
776
+ version = ""
777
+ diagnostics .EmitNoGoModAndGoEnvSupported (msg )
778
+ }
775
779
}
776
780
777
781
return msg , version
@@ -789,10 +793,18 @@ func compareVersions(v versionInfo) (msg, version string) {
789
793
"file (" + v .goModVersion + ")."
790
794
version = v .goModVersion
791
795
diagnostics .EmitVersionGoModHigherVersionEnvironment (msg )
796
+ } else if outsideSupportedRange (v .goEnvVersion ) {
797
+ msg = "The version of Go installed in the environment (" + v .goEnvVersion +
798
+ ") is outside of the supported range (" + minGoVersion + "-" + maxGoVersion + "). " +
799
+ "Writing an environment file specifying the version of Go from the `go.mod` file (" +
800
+ v .goModVersion + ")."
801
+ version = v .goModVersion
802
+ diagnostics .EmitVersionGoModSupportedAndGoEnvUnsupported (msg )
792
803
} else {
804
+
793
805
msg = "The version of Go installed in the environment (" + v .goEnvVersion +
794
- ") is high enough for the version found in the `go.mod` file (" + v . goModVersion +
795
- "). Writing an environment file not specifying any version of Go."
806
+ ") is supported and is high enough for the version found in the `go.mod` file (" +
807
+ v . goModVersion + "). Writing an environment file not specifying any version of Go."
796
808
version = ""
797
809
diagnostics .EmitVersionGoModNotHigherVersionEnvironment (msg )
798
810
}
0 commit comments