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.
This commit is contained in:
Chris Smowton 2022-05-13 17:32:00 +01:00
Родитель 570d3f47c4
Коммит 2930bd4cc2
1 изменённых файлов: 2 добавлений и 2 удалений

Просмотреть файл

@ -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. ")
}
}
}
}