gpt4 book ai didi

travis-ci 中的 go.mod 变化

转载 作者:IT王子 更新时间:2023-10-29 01:25:42 26 4
gpt4 key购买 nike

我已经升级我的项目以使用 go 1.11.2 模块支持。但是,我遇到了一个非常烦人的问题。 go.mod 文件在 CI 中不断变化。每天都有不同的文件。今天 go.sum 中的行是:

golang.org/x/net v0.0.0-20190213061140-3a22650c66bd h1:HuTn7WObtcDo9uEEU7rEqL0jYthdXAmZ6PP+meazmaU=
golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=

go.mod 是:

golang.org/x/net v0.0.0-20190213061140-3a22650c66bd // indirect

我没有更新任何依赖项。他们没有锁定!为什么不?如果依赖关系不断变化,这将是一个非常大的问题。但是,我没有看到其他人对这个问题尖叫。所以我一定做错了什么。

我正在使用 go mod tidygit diff --exit-code 之前同步它。这在本地有效,但在 Travis-CI 上无效。我认为这是一个问题,因为在 Travis-CI 上它需要获取依赖项,并且由于这些依赖项不使用语义版本控制,Go 获取最新的,它会在每次提交到 master 时发生变化。如果您同意这是问题所在,我该如何锁定 Go 模块的依赖项?

最佳答案

The wiki explains如何使用未选择加入 go modules 的包

这是一个相关的片段:

If the repository does not have any valid semver tags, then the repository's version will be recorded with a "pseudo-version" such as v0.0.0-20171006230638-a6e239ea1c69 (which includes a timestamp and a commit hash, and which are designed to allow a total ordering across versions recored in go.mod and to make it easier to reason about which recorded versions are "later" than another recorded version).

您也可以要求特定的提交哈希值:

When needed, more specific versions of dependencies can be chosen with commands such as go get foo@v1.2.3, go get foo@master, go get foo@e3702bed2, or by editing go.mod directly.

关于travis-ci 中的 go.mod 变化,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54714355/

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