添加和使用 Go 模块库的次要版本,主要版本大于 2。

huangapple go评论85阅读模式
英文:

Adding and Using a Go Modules Library Minor Version With Major Version > 2

问题

我一直在将我们的私有库转换为Go Modules,并且已经成功地解决了一些初始障碍,例如发布和使用一个新的主要版本的库,例如tssgit.reyrey.com/teschste/go-httpmailer/v3

然而,现在我需要将该库从v3.0.0更新到v3.1.0,但是遇到了问题。根据我在网上找到的信息,我了解到只需要在go.mod文件中保持声明不变module tssgit.reyrey.com/teschste/go-httpmailer/v3,然后发布新版本即可。我可以在我们的代码库中看到新的发布版本:
[我尝试添加一张图片来展示,但由于某种原因无法添加]

当我尝试在应用程序中使用这个新版本时,我首先尝试了以下命令:
> go get tssgit.reyrey.com/teschste/go-httpmailer/v3

但是失败了,显示如下错误:
> go: module tssgit.reyrey.com/teschste/go-httpmailer@upgrade found (v2.1.0+incompatible), but does not contain package tssgit.reyrey.com/teschste/go-httpmailer/v3

然后我尝试了以下命令:
> go get tssgit.reyrey.com/teschste/go-httpmailer/v3@v3.1.0

但是失败了,显示如下错误:
> go: tssgit.reyrey.com/teschste/go-httpmailer/v3@v3.1.0: invalid version: go.mod has non-.../v3 module path "tssgit.reyrey.com/teschste/go-httpmailer/v3.1" (and .../v3/go.mod does not exist) at revision v3.1.0

关于设置主要版本的信息在网上有很多,但我还没有找到解决我的具体问题的方法。我相信我可能遗漏了一些简单的东西,但是目前我不知道是什么。如果有任何帮助,将不胜感激!

英文:

I have been working on converting our private libraries to Go Modules and I got through the initial hurdles of publishing and using a new major version of a library for example, tssgit.reyrey.com/teschste/go-httpmailer/v3.

However, I now need to publish an update to that library from v3.0.0 to v3.1.0 and I am having issues. My understanding from what I found online is that I leave the declaration in go.mod the same module tssgit.reyrey.com/teschste/go-httpmailer/v3 and simply publish the new version. I can see the new release in our repository:
[I tried adding an image to show it but it would not add for some reason]

When I attempt to use that new version in an application, I first tried:
> go get tssgit.reyrey.com/teschste/go-httpmailer/v3

but that failed with:
> go: module tssgit.reyrey.com/teschste/go-httpmailer@upgrade found (v2.1.0+incompatible), but does not contain package tssgit.reyrey.com/teschste/go-httpmailer/v3

Then I tried:
> go get tssgit.reyrey.com/teschste/go-httpmailer/v3@v3.1.0

but that failed with:
> go: tssgit.reyrey.com/teschste/go-httpmailer/v3@v3.1.0: invalid version: go.mod has non-.../v3 module path "tssgit.reyrey.com/teschste/go-httpmailer/v3.1" (and .../v3/go.mod does not exist) at revision v3.1.0

There is a lot of information online about setting up a major version but I have not found anything so far that addresses my specific issue.
I am sure I am missing something simple but at this point, I have no idea what it is. Any help would be appreciated!

答案1

得分: 2

最后的错误消息表明,在你的 go.mod 文件中的 v3.1.0 版本中,你有以下代码:

module tssgit.reyrey.com/teschste/go-httpmailer

而不是

module tssgit.reyrey.com/teschste/go-httpmailer/v3
英文:

The last error message suggests that in your go.mod file in the v3.1.0 release you have

module tssgit.reyrey.com/teschste/go-httpmailer

instead of

module tssgit.reyrey.com/teschste/go-httpmailer/v3

答案2

得分: 0

经过更多的谷歌搜索后,我向内部的其他人寻求了一些帮助,以确保我没有错过任何明显的东西,而他们也没有遇到同样的问题。我们尝试了几种方法,但最终发现是我的安装中有一些问题导致失败(不知道是什么问题),所以我卸载了Go和git,重新安装了Go和git,并在重新安装后解决了配置问题,我的问题解决了。我希望我能给出一个更好的答案,但我没有。

希望没有其他人需要经历这个问题。

英文:

After a lot more Googling, I asked for some help from someone else internally, to ensure I was not just missing something obvious and they were not having the same problem. We tries several things but what it boiled down to was there was something in my installation that was causing it to fail (no idea what), so I de-installed Go, de-installed git, re-installed Go, and re-installed git, and after cleaning up the configuration issues from re-installation, my problem has gone away. I wish I had a better answer but I do not.

Hopefully nobody else has to go through this.

huangapple
  • 本文由 发表于 2023年6月6日 01:45:15
  • 转载请务必保留本文链接:https://go.coder-hub.com/76408835.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定