vendorDir = filepath.Join(modRoots[0], "vendor")
}
if fi, err := fsys.Stat(vendorDir); err == nil && fi.IsDir() {
- modGo := "unspecified"
if goVersion != "" {
if gover.Compare(goVersion, "1.14") < 0 {
// The go version is less than 1.14. Don't set -mod=vendor by default.
// Since a vendor directory exists, we should record why we didn't use it.
// This message won't normally be shown, but it may appear with import errors.
- cfg.BuildModReason = fmt.Sprintf("Go version in "+versionSource+" is %s, so vendor directory was not used.", modGo)
+ cfg.BuildModReason = fmt.Sprintf("Go version in "+versionSource+" is %s, so vendor directory was not used.", goVersion)
} else {
vendoredWorkspace, err := modulesTextIsForWorkspace(vendorDir)
if err != nil {
return
}
}
- modGo = goVersion
+ } else {
+ cfg.BuildModReason = fmt.Sprintf("Go version in " + versionSource + " is unspecified, so vendor directory was not used.")
}
-
}
}
--- /dev/null
+cd thirteen
+! go list -deps
+stderr '(Go version in go.mod is 1.13, so vendor directory was not used.)'
+
+cd ../unspecified
+! go list -deps
+stderr '(Go version in go.mod is unspecified, so vendor directory was not used.)'
+
+-- thirteen/foo.go --
+package foo
+
+import _ "github.com/foo/bar"
+-- thirteen/go.mod --
+module example.com
+
+go 1.13
+-- thirteen/vendor/github.com/foo/bar/bar.go --
+package bar
+-- unspecified/foo.go --
+package foo
+
+import _ "github.com/foo/bar"
+-- unspecified/go.mod --
+module example.com
+-- unspecified/vendor/github.com/foo/bar/bar.go --
+package bar
\ No newline at end of file