2

go.mod file

go 1.13

require (
  ...
  gorm.io/gorm v1.20.5
) 

When I run go mod download then my go.mod file becomes

go 1.13

require (
  ...
  gorm.io/gorm v1.20.7
) 

How can I stop this upgrade while running go mod download?

1 Answers1

3

You can try -mod=readonly when running code

reference is here https://golang.org/ref/mod#go-mod-file-updates

The -mod=readonly flag prevents commands from automatically updating go.mod. However, if a command needs to perform an action that would update to go.mod, it will report an error. For example, if go build is asked to build a package not provided by any module in the build list, go build will report an error instead of looking up the module and updating requirements in go.mod.

Bakurits
  • 402
  • 3
  • 11