转到mod供应商,而无需更新到最新 [英] go mod vendor without update to latest
问题描述
我正在尝试确定是否可以在不使用go工具更新go.mod文件的情况下运行go mod供应商.
I’m trying to figure out if it’s possible to run go mod vendor without the go tool updating my go.mod file.
我专门 go package/subpackage @ commit
,并用正确的版本提交我的 go.mod
.
I specifically go get package/subpackage@commit
and commit my go.mod
with the correct version.
然后我运行 go mod vendor
,它会自动更改我刚刚专门设置的软件包的版本.
Then I run go mod vendor
and it automatically bumps the version of the package that I just specifically set.
I’ve looked at this page to no avail: https://github.com/golang/go/wiki/Modules#how-do-i-use-vendoring-with-modules-is-vendoring-going-away
我需要使用供应商,因为我运行的脚本可以编辑一些供应商的部门.我正在查看以下构建流程:
I need to use vendor because I run a script that edits some of the vendored deps., I’m looking at the following build flow:
GO111MODULE=on go get package/subpackge@commit
GO111MODULE=on go mod vendor
./Script/patch_vendors.sh --write
GO111MODULE=off go build
我的另一种选择是修改复制的源代码,mod供应商将其下载到任何地方,但是不知道该如何处理.
My other option is modifying the copied source wherever go mod vendor donwloads it to, but not sure how to approach that.
预先感谢
推荐答案
每个 https://tip.golang.org/cmd/go/#hdr-Maintaining_module_requirements :
go
命令本身会自动更新go.mod
文件,以保持标准格式和require
语句的准确性.
The
go
command itself automatically updates thego.mod
file to maintain a standard formatting and the accuracy ofrequire
statements.
任何发现不熟悉的导入的go命令都会查找包含该导入的模块,并将该模块的最新版本自动添加到go.mod中.[…]
Any go command that finds an unfamiliar import will look up the module containing that import and add the latest version of that module to go.mod automatically. […]
任何go命令都可以确定缺少模块要求,因此必须添加[…].
Any go command can determine that a module requirement is missing and must be added […].
go mod vendor
命令会在软件包及其测试的所有可传递导入中复制,因此它将自动更新 go.mod
文件以确保所有存在已导入的软件包.
The go mod vendor
command copies in all of the transitive imports of your packages and their tests, so it will automatically update the go.mod
file to ensure that all of the imported packages are present.
因此,这里的问题很可能是您为 package/subpackage
选择的 commit
无法提供某些出现在程序的可移植导入中的软件包.如果正确,您应该发现全部列出
,全部测试
和 go mod tidy
都对模块的目录进行了相同的编辑要求.
So the problem here is likely that the commit
you've selected for package/subpackage
fails to provide some package that appears in the transitive imports of your program. If that is correct, you should find that go list all
, go test all
, and go mod tidy
all make that same edit to your module's requirements.
这篇关于转到mod供应商,而无需更新到最新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!