Reputation: 21
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
?
Upvotes: 2
Views: 2130
Reputation: 402
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.
Upvotes: 3