@@ -308,7 +308,7 @@ func getModMode(depMode DependencyInstallerMode) ModMode {
308
308
}
309
309
310
310
// 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 {
312
312
if modMode == ModVendor {
313
313
// fix go vendor issues with go versions >= 1.14 when no go version is specified in the go.mod
314
314
// 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
318
318
// we work around this by adding an explicit go version of 1.13, which is the last version
319
319
// where this is not an issue
320
320
if depMode == GoGetWithModules {
321
- if ! goDirectiveFound {
321
+ if ! goModVersionFound {
322
322
// if the go.mod does not contain a version line
323
323
modulesTxt , err := os .ReadFile ("vendor/modules.txt" )
324
324
if err != nil {
@@ -672,10 +672,10 @@ func installDependenciesAndBuild() {
672
672
os .Setenv ("GO111MODULE" , "auto" )
673
673
}
674
674
675
- _ , goDirectiveFound := tryReadGoDirective (depMode )
675
+ _ , goModVersionFound := tryReadGoDirective (depMode )
676
676
677
677
modMode := getModMode (depMode )
678
- modMode = fixGoVendorIssues (modMode , depMode , goDirectiveFound )
678
+ modMode = fixGoVendorIssues (modMode , depMode , goModVersionFound )
679
679
680
680
tryUpdateGoModAndGoSum (modMode , depMode )
681
681
@@ -742,14 +742,14 @@ func outsideSupportedRange(version string) bool {
742
742
// a diagnostic and return an empty version to indicate that we should not attempt to install a
743
743
// different version of Go.
744
744
func checkForUnsupportedVersions (v versionInfo ) (msg , version string ) {
745
- if v .goDirectiveFound && outsideSupportedRange (v .goModVersion ) {
745
+ if v .goModVersionFound && outsideSupportedRange (v .goModVersion ) {
746
746
msg = "The version of Go found in the `go.mod` file (" + v .goModVersion +
747
747
") is outside of the supported range (" + minGoVersion + "-" + maxGoVersion + ")."
748
748
version = ""
749
749
diagnostics .EmitUnsupportedVersionGoMod (msg )
750
750
}
751
751
752
- if v .goInstallationFound && outsideSupportedRange (v .goEnvVersion ) {
752
+ if v .goEnVersionFound && outsideSupportedRange (v .goEnvVersion ) {
753
753
msg = "The version of Go installed in the environment (" + v .goEnvVersion +
754
754
") is outside of the supported range (" + minGoVersion + "-" + maxGoVersion + ")."
755
755
version = ""
@@ -759,26 +759,26 @@ func checkForUnsupportedVersions(v versionInfo) (msg, version string) {
759
759
return msg , version
760
760
}
761
761
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
763
763
// a diagnostic and return the version to install, or the empty string if we should not attempt to
764
764
// install a version of Go. We assume that `checkForUnsupportedVersions` has already been
765
765
// called, so any versions that are found are within the supported range.
766
766
func checkForVersionsNotFound (v versionInfo ) (msg , version string ) {
767
- if ! v .goInstallationFound && ! v .goDirectiveFound {
767
+ if ! v .goEnVersionFound && ! v .goModVersionFound {
768
768
msg = "No version of Go installed and no `go.mod` file found. Writing an environment " +
769
769
"file specifying the maximum supported version of Go (" + maxGoVersion + ")."
770
770
version = maxGoVersion
771
771
diagnostics .EmitNoGoModAndNoGoEnv (msg )
772
772
}
773
773
774
- if ! v .goInstallationFound && v .goDirectiveFound {
774
+ if ! v .goEnVersionFound && v .goModVersionFound {
775
775
msg = "No version of Go installed. Writing an environment file specifying the version " +
776
776
"of Go found in the `go.mod` file (" + v .goModVersion + ")."
777
777
version = v .goModVersion
778
778
diagnostics .EmitNoGoEnv (msg )
779
779
}
780
780
781
- if v .goInstallationFound && ! v .goDirectiveFound {
781
+ if v .goEnVersionFound && ! v .goModVersionFound {
782
782
msg = "No `go.mod` file found. Version " + v .goEnvVersion + " installed in the environment."
783
783
version = ""
784
784
diagnostics .EmitNoGoMod (msg )
@@ -864,16 +864,16 @@ func writeEnvironmentFile(version string) {
864
864
}
865
865
866
866
type 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.
871
871
}
872
872
873
873
func (v versionInfo ) String () string {
874
874
return fmt .Sprintf (
875
875
"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 )
877
877
}
878
878
879
879
// Check if Go is installed in the environment.
@@ -886,10 +886,10 @@ func isGoInstalled() bool {
886
886
func identifyEnvironment () {
887
887
var v versionInfo
888
888
depMode := getDepMode ()
889
- v .goModVersion , v .goDirectiveFound = tryReadGoDirective (depMode )
889
+ v .goModVersion , v .goModVersionFound = tryReadGoDirective (depMode )
890
890
891
- v .goInstallationFound = isGoInstalled ()
892
- if v .goInstallationFound {
891
+ v .goEnVersionFound = isGoInstalled ()
892
+ if v .goEnVersionFound {
893
893
v .goEnvVersion = getEnvGoVersion ()[2 :]
894
894
}
895
895
0 commit comments