@@ -308,7 +308,7 @@ func getModMode(depMode DependencyInstallerMode) ModMode {
308308}
309309
310310// fixGoVendorIssues fixes issues with go vendor for go version >= 1.14
311- func fixGoVendorIssues (modMode ModMode , depMode DependencyInstallerMode , goDirectiveFound bool ) ModMode {
311+ func fixGoVendorIssues (modMode ModMode , depMode DependencyInstallerMode , goModVersionFound bool ) ModMode {
312312 if modMode == ModVendor {
313313 // fix go vendor issues with go versions >= 1.14 when no go version is specified in the go.mod
314314 // if this is the case, and dependencies were vendored with an old go version (and therefore
@@ -318,7 +318,7 @@ func fixGoVendorIssues(modMode ModMode, depMode DependencyInstallerMode, goDirec
318318 // we work around this by adding an explicit go version of 1.13, which is the last version
319319 // where this is not an issue
320320 if depMode == GoGetWithModules {
321- if ! goDirectiveFound {
321+ if ! goModVersionFound {
322322 // if the go.mod does not contain a version line
323323 modulesTxt , err := os .ReadFile ("vendor/modules.txt" )
324324 if err != nil {
@@ -672,10 +672,10 @@ func installDependenciesAndBuild() {
672672 os .Setenv ("GO111MODULE" , "auto" )
673673 }
674674
675- _ , goDirectiveFound := tryReadGoDirective (depMode )
675+ _ , goModVersionFound := tryReadGoDirective (depMode )
676676
677677 modMode := getModMode (depMode )
678- modMode = fixGoVendorIssues (modMode , depMode , goDirectiveFound )
678+ modMode = fixGoVendorIssues (modMode , depMode , goModVersionFound )
679679
680680 tryUpdateGoModAndGoSum (modMode , depMode )
681681
@@ -742,14 +742,14 @@ func outsideSupportedRange(version string) bool {
742742// a diagnostic and return an empty version to indicate that we should not attempt to install a
743743// different version of Go.
744744func checkForUnsupportedVersions (v versionInfo ) (msg , version string ) {
745- if v .goDirectiveFound && outsideSupportedRange (v .goModVersion ) {
745+ if v .goModVersionFound && outsideSupportedRange (v .goModVersion ) {
746746 msg = "The version of Go found in the `go.mod` file (" + v .goModVersion +
747747 ") is outside of the supported range (" + minGoVersion + "-" + maxGoVersion + ")."
748748 version = ""
749749 diagnostics .EmitUnsupportedVersionGoMod (msg )
750750 }
751751
752- if v .goInstallationFound && outsideSupportedRange (v .goEnvVersion ) {
752+ if v .goEnVersionFound && outsideSupportedRange (v .goEnvVersion ) {
753753 msg = "The version of Go installed in the environment (" + v .goEnvVersion +
754754 ") is outside of the supported range (" + minGoVersion + "-" + maxGoVersion + ")."
755755 version = ""
@@ -759,26 +759,26 @@ func checkForUnsupportedVersions(v versionInfo) (msg, version string) {
759759 return msg , version
760760}
761761
762- // Check if either `v.goInstallationFound ` or `v.goDirectiveFound ` are false. If so, emit
762+ // Check if either `v.goEnVersionFound ` or `v.goModVersionFound ` are false. If so, emit
763763// a diagnostic and return the version to install, or the empty string if we should not attempt to
764764// install a version of Go. We assume that `checkForUnsupportedVersions` has already been
765765// called, so any versions that are found are within the supported range.
766766func checkForVersionsNotFound (v versionInfo ) (msg , version string ) {
767- if ! v .goInstallationFound && ! v .goDirectiveFound {
767+ if ! v .goEnVersionFound && ! v .goModVersionFound {
768768 msg = "No version of Go installed and no `go.mod` file found. Writing an environment " +
769769 "file specifying the maximum supported version of Go (" + maxGoVersion + ")."
770770 version = maxGoVersion
771771 diagnostics .EmitNoGoModAndNoGoEnv (msg )
772772 }
773773
774- if ! v .goInstallationFound && v .goDirectiveFound {
774+ if ! v .goEnVersionFound && v .goModVersionFound {
775775 msg = "No version of Go installed. Writing an environment file specifying the version " +
776776 "of Go found in the `go.mod` file (" + v .goModVersion + ")."
777777 version = v .goModVersion
778778 diagnostics .EmitNoGoEnv (msg )
779779 }
780780
781- if v .goInstallationFound && ! v .goDirectiveFound {
781+ if v .goEnVersionFound && ! v .goModVersionFound {
782782 msg = "No `go.mod` file found. Version " + v .goEnvVersion + " installed in the environment."
783783 version = ""
784784 diagnostics .EmitNoGoMod (msg )
@@ -864,16 +864,16 @@ func writeEnvironmentFile(version string) {
864864}
865865
866866type versionInfo struct {
867- goModVersion string
868- goDirectiveFound bool
869- goEnvVersion string
870- goInstallationFound bool
867+ goModVersion string // The version of Go found in the go directive in the `go.mod` file.
868+ goModVersionFound bool // Whether a `go` directive was found in the `go.mod` file.
869+ goEnvVersion string // The version of Go found in the environment.
870+ goEnVersionFound bool // Whether an installation of Go was found in the environment.
871871}
872872
873873func (v versionInfo ) String () string {
874874 return fmt .Sprintf (
875875 "go.mod version: %s, go.mod directive found: %t, go env version: %s, go installation found: %t" ,
876- v .goModVersion , v .goDirectiveFound , v .goEnvVersion , v .goInstallationFound )
876+ v .goModVersion , v .goModVersionFound , v .goEnvVersion , v .goEnVersionFound )
877877}
878878
879879// Check if Go is installed in the environment.
@@ -886,10 +886,10 @@ func isGoInstalled() bool {
886886func identifyEnvironment () {
887887 var v versionInfo
888888 depMode := getDepMode ()
889- v .goModVersion , v .goDirectiveFound = tryReadGoDirective (depMode )
889+ v .goModVersion , v .goModVersionFound = tryReadGoDirective (depMode )
890890
891- v .goInstallationFound = isGoInstalled ()
892- if v .goInstallationFound {
891+ v .goEnVersionFound = isGoInstalled ()
892+ if v .goEnVersionFound {
893893 v .goEnvVersion = getEnvGoVersion ()[2 :]
894894 }
895895
0 commit comments