Skip to content

Commit 2930bd4

Browse files
committed
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.
1 parent 570d3f4 commit 2930bd4

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

extractor/cli/go-autobuilder/go-autobuilder.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,8 @@ func main() {
290290
}
291291
}
292292

293-
if depMode == GoGetWithModules {
293+
// Go 1.16 and later won't automatically attempt to update go.mod / go.sum during package loading, so try to update them here:
294+
if depMode == GoGetWithModules && semver.Compare(getEnvGoSemVer(), "1.16") >= 0 {
294295
// stat go.mod and go.sum
295296
beforeGoModFileInfo, beforeGoModErr := os.Stat("go.mod")
296297
if beforeGoModErr != nil {
@@ -324,7 +325,6 @@ func main() {
324325
log.Println("We have run `go mod tidy -e` and it altered go.sum. You may wish to check these changes into version control. ")
325326
}
326327
}
327-
328328
}
329329
}
330330

0 commit comments

Comments
 (0)