From 859b427881722bbd046db3aaca328e47773b59ea Mon Sep 17 00:00:00 2001 From: Chris Smowton Date: Wed, 26 Aug 2020 11:53:50 +0100 Subject: [PATCH] Check if the vendor/ directory is usable, even after a successful build --- extractor/cli/go-autobuilder/go-autobuilder.go | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/extractor/cli/go-autobuilder/go-autobuilder.go b/extractor/cli/go-autobuilder/go-autobuilder.go index 99f9af145c9..6fee70f8137 100644 --- a/extractor/cli/go-autobuilder/go-autobuilder.go +++ b/extractor/cli/go-autobuilder/go-autobuilder.go @@ -393,16 +393,17 @@ func main() { tryBuild("build", "./build") || tryBuild("build.sh", "./build.sh") - if !buildSucceeded { - if modMode == ModVendor { - // test if running `go` with -mod=vendor works, and if it doesn't, try to fallback to -mod=mod - // or not set if the go version < 1.14. - if !checkVendor() { - modMode = modModIfSupported() - log.Println("The vendor directory is not consistent with the go.mod; not using vendored dependencies.") - } + if modMode == ModVendor { + // test if running `go` with -mod=vendor works, and if it doesn't, try to fallback to -mod=mod + // or not set if the go version < 1.14. Note we check this post-build in case the build brings + // the vendor directory up to date. + if !checkVendor() { + modMode = modModIfSupported() + log.Println("The vendor directory is not consistent with the go.mod; not using vendored dependencies.") } + } + if !buildSucceeded { if modMode == ModVendor { log.Printf("Skipping dependency installation because a Go vendor directory was found.") } else {