gpt4 book ai didi

go - 运行go mod下载时如何强制使用特定的软件包版本?

转载 作者:行者123 更新时间:2023-12-03 10:07:22 25 4
gpt4 key购买 nike

go.mod文件

go 1.13

require (
...
gorm.io/gorm v1.20.5
)
当我运行 go mod download时,我的go.mod文件变为
go 1.13

require (
...
gorm.io/gorm v1.20.7
)
运行 go mod download时如何停止此升级?

最佳答案

您可以在运行代码时尝试-mod=readonly引用在这里https://golang.org/ref/mod#go-mod-file-updates

The -mod=readonly flag prevents commands from automatically updatinggo.mod. However, if a command needs to perform an action that wouldupdate to go.mod, it will report an error. For example, if go build isasked 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 andupdating requirements in go.mod.

关于go - 运行go mod下载时如何强制使用特定的软件包版本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65391236/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com