@@ -737,12 +737,6 @@ func checkForUnsupportedVersions(v versionInfo) (msg, version string) {
737737 "). Writing an environment file not specifying any version of Go."
738738 version = ""
739739 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 )
746740 }
747741
748742 return msg , version
@@ -768,10 +762,20 @@ func checkForVersionsNotFound(v versionInfo) (msg, version string) {
768762 }
769763
770764 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+ }
775779 }
776780
777781 return msg , version
@@ -789,10 +793,18 @@ func compareVersions(v versionInfo) (msg, version string) {
789793 "file (" + v .goModVersion + ")."
790794 version = v .goModVersion
791795 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 )
792803 } else {
804+
793805 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."
796808 version = ""
797809 diagnostics .EmitVersionGoModNotHigherVersionEnvironment (msg )
798810 }
0 commit comments