如何从sumsdb中删除一个模块?

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

Go: how to remove a module from sumsdb

问题

我在这里犯了一个错误。不幸的是,那个问题被错误地关闭为“重复”,而提出的问题实际上与我的问题不同

让我用另一种方式重新表达我的问题:作为一个模块的作者,我如何从Go的“sumsdb”中移除一个模块,以便修复像描述的那样的错误。

以下是原始问题的引用。


编辑:这个问题被管理员关闭了,但是给出的链接并没有回答我的问题,它给出了一个不同的错误信息:

https://stackoverflow.com/questions/67678203/why-does-go-get-fail-with-invalid-version-unknown-revision

我将重新表达我的问题:

我从一个提交中删除了标签v1.0.0,并给另一个提交打了标签。现在我发现该存储库不再可用。要验证:您可以执行以下操作:

  1. 克隆https://github.com/xrfang/hap
  2. 进入example目录,然后运行go build .

这个问题不仅发生在我的电脑上,而且发生在任何试图使用上述存储库的人身上。

我想知道这个问题是否会随着时间的推移而消失(因为缓存过期了?),还是我需要做些什么?如果它会自行修复,我想知道缓存的有效时间有多长?如果不会,我想知道如何修复它。我希望不要使用类似GOPRIVATE的东西,因为这个存储库将是公开的(开源)。

原始帖子:

我编写了一个HTTP参数解析工具,并将其放在github.com/xrfang/hap。Git日志如下:

* d8cee08 2022-02-14 | implemented http.Handler interface (HEAD -> master, tag: v1.0.0, origin/master, origin/HEAD) [xrfang]
* 171dc29 2022-02-10 | updated go.mod for example [xrfang]
* d2cea3c 2022-02-09 | added example [xrfang]
* 202d959 2022-02-09 | bug fix in error handling [xrfang]
* ... ...

问题是,之前,我将提交d2cea3c标记为v1.0.0。后来我发现它不是最佳选择,并添加了一些新代码。新代码与v1.0.0不兼容,所以我应该将其命名为v2.0.0。然而,由于这个工具是新编写的,我是唯一的用户。我认为将其命名为v2.0.0是愚蠢的。所以我只是删除了并重新标记了v1.0.0为最新的提交d8cee08

问题是,Go抱怨版本不是“真实的”。然后我删除了go.sum,并执行了go clean -modcachego get -ugo mod tidy,但没有效果。最后一次尝试是:

$ go get -u
# example
./main.go:30:11: at.Init undefined (type apiTest has no field or method Init)
./main.go:39:2: undefined: hap.Register

我的问题是:

1)Go如何管理其存储库?我之前发现,当我更新我的模块并将其推送到GitHub后,示例经常无法编译,除非我在go.mod中使用replace,或者只是等待一段时间(例如30分钟)。似乎有一个中央的“查找表”,定期更新,因此经常滞后于模块的更新?

2)如何修复我当前的重新标记版本的问题?

英文:

I made a mistake described here. Unfortunately that question is wrongly closed as "duplicate", and the proposed question is actually not same as mime.

Let me rephrase my question in another way: as a module author, how can I remove a module from Go's "sumsdb" so that mistake like described can be fixed.

Original question pasted below for reference.


EDIT: this question was closed by moderator, but it is NOT answered by the given uri, which gives a different error message:

https://stackoverflow.com/questions/67678203/why-does-go-get-fail-with-invalid-version-unknown-revision

I'll rephrase my questions:

I removed tag v1.0.0 from a commit, and tagged another commit. Now I found that the repository is not usable anymore. To verify: you may just do the following:

  1. Clone https://github.com/xrfang/hap
  2. cd into the example directory, then run go build .

This problem not only happens on my PC, but on anyone trying to use the above repo.

I wonder if the problem will disappear over time (as cache expires?) or I have to do something? If it will heal itself, I wonder how long is the cache valid time? If not, I would like to know how to fix that. I hope not using things like GOPRIVATE, as this repo is going to be public (open source).

original post:

I write a http argument parsing tool, and put it at github.com/xrfang/hap. The git log is:

* d8cee08 2022-02-14 | implemented http.Handler interface (HEAD -> master, tag: v1.0.0, origin/master, origin/HEAD) [xrfang]
* 171dc29 2022-02-10 | updated go.mod for example [xrfang]
* d2cea3c 2022-02-09 | added example [xrfang]
* 202d959 2022-02-09 | bug fix in error handling [xrfang]
* ... ...

Problem is, previouly, I tagged commit d2cea3c as v1.0.0. Later I found it not optimal and added some new code. The new code is NOT compatible with v1.0.0, so I should make it v2.0.0. However, as this tool is newly written and I am the only user. I think it is stupid to make it v2.0.0. So I just removed and retagged v1.0.0 to the latest commit d8cee08.

The problem is, go complained that the version is not "authentic". I then removed go.sum, and did go clean -modcache, go get -u, go mod tidy, to no avail. The last try is:

$ go get -u
# example
./main.go:30:11: at.Init undefined (type apiTest has no field or method Init)
./main.go:39:2: undefined: hap.Register

My questions are:

  1. How does Go manage its repository? I previously found that after I updated my module and push it to github, the example often fail to compile, unless I use replace in go.mod, or just wait for a while (e.g. 30 minute). It seems that there is a central "look up table" which is updated periodically and hence oftem lags behind while modules update?

  2. How to fix my current problem of a re-tagged version?

答案1

得分: 2

你的理解是正确的,就像你在链接的问题中描述的那样。

要么:

  • 发布 v2.0.0
  • 使用 GOPRIVATE
  • 发布 v1.1.0
英文:
  1. Your understanding is correct as also described in the question you linked.

  2. Either

  • Publish v2.0.0
  • Live with GOPRIVATE
  • Publish v1.1.0

huangapple
  • 本文由 发表于 2022年2月15日 13:12:02
  • 转载请务必保留本文链接:https://go.coder-hub.com/71121382.html
匿名

发表评论

匿名网友

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

确定