From 2930bd4cc24489be4a915a6e759e1872a8e81ef3 Mon Sep 17 00:00:00 2001 From: Chris Smowton Date: Fri, 13 May 2022 17:32:00 +0100 Subject: [PATCH] Only attempt go.mod updating if go >= 1.16 Prior to this (a) Go will attempt to update go.mod/sum anyhow, and (b) the `mod tidy -e` option isn't available. --- extractor/cli/go-autobuilder/go-autobuilder.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/extractor/cli/go-autobuilder/go-autobuilder.go b/extractor/cli/go-autobuilder/go-autobuilder.go index 681bf666..07b8a6cb 100644 --- a/extractor/cli/go-autobuilder/go-autobuilder.go +++ b/extractor/cli/go-autobuilder/go-autobuilder.go @@ -290,7 +290,8 @@ func main() { } } - if depMode == GoGetWithModules { + // Go 1.16 and later won't automatically attempt to update go.mod / go.sum during package loading, so try to update them here: + if depMode == GoGetWithModules && semver.Compare(getEnvGoSemVer(), "1.16") >= 0 { // stat go.mod and go.sum beforeGoModFileInfo, beforeGoModErr := os.Stat("go.mod") if beforeGoModErr != nil { @@ -324,7 +325,6 @@ func main() { log.Println("We have run `go mod tidy -e` and it altered go.sum. You may wish to check these changes into version control. ") } } - } }