gpt4 book ai didi

go - 为什么这个版本标签会导致错误?

转载 作者:IT王子 更新时间:2023-10-29 02:34:59 27 4
gpt4 key购买 nike

在我的 go.mod 文件中,我有:

require (
// ... editted for brevity
github.com/Liquid-Labs/catalyst-firewrap v2.0.0-prototype.3
// ...
)

当我尝试构建依赖于此包的另一个包时,我得到:无效模块:github.com/Liquid-Labs/catalyst-firewrap should be v0 or v1, not v2 (v2.0.0-prototype. 3)

在 go 模块化之前有一个重写,那时我没有标记东西,所以没有 v1 ......这是问题吗?我没有运气在这里找到对潜在问题的解释。

最佳答案

根据 Go modules wiki :

If the module is version v2 or higher, the major version of the module must be included as a /vN at the end of the module paths used in go.mod files (e.g., module github.com/my/mod/v2, require github.com/my/mod/v2 v2.0.0) and in the package import path (e.g., import "github.com/my/mod/v2/mypkg").

同一文档引用了官方 Go FAQ 中的基本原理:

Packages intended for public use should try to maintain backwards compatibility as they evolve. The Go 1 compatibility guidelines are a good reference here: don't remove exported names, encourage tagged composite literals, and so on. If different functionality is required, add a new name instead of changing an old one. If a complete break is required, create a new package with a new import path.

和:

If an old package and a new package have the same import path, the new package must be backwards compatible with the old package.

关于go - 为什么这个版本标签会导致错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57212647/

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