autobuilder: Use -mod=mod for vendor directories wihtout modules.txt

This commit is contained in:
Sauyon Lee
2020-08-25 03:51:13 -07:00
committed by Chris Smowton
parent 70d425d317
commit 8f6b25e0ac
2 changed files with 12 additions and 0 deletions

View File

@@ -244,7 +244,10 @@ func main() {
// skip the dependency installation step and run the extractor with `-mod=vendor`
if util.FileExists("vendor/modules.txt") {
modMode = ModVendor
} else if util.DirExists("vendor") {
modMode = modModIfSupported()
}
if modMode == ModVendor {
// fix go vendor issues with go versions >= 1.14 when no go version is specified in the go.mod
// if this is the case, and dependencies were vendored with an old go version (and therefore

View File

@@ -91,3 +91,12 @@ func FileExists(filename string) bool {
}
return err == nil && !info.IsDir()
}
// DirExists tests whether `filename` exists and is a directory.
func DirExists(filename string) bool {
info, err := os.Stat(filename)
if err != nil && !os.IsNotExist(err) {
log.Printf("Unable to stat %s: %s\n", filename, err.Error())
}
return err == nil && info.IsDir()
}