英文:
Why does “go get” sometimes retrieve an outdated commit?
问题
我创建了一个Go模块,并将其放在github.com/bronger/abcde
。错误地,在其go.mod
文件中将其声明为module abcde
。因此,在Dockerfile中(即没有我的本地程序副本的情况下)执行go get github.com/bronger/abcde
会失败,错误信息如下:
#10 0.824 go: downloading github.com/bronger/abcde v0.0.0-20210813180406-8d5688e6c805 #10 0.866 go get: github.com/bronger/abcde@none updating to
#10 0.866 github.com/bronger/abcde@v0.0.0-20210813180406-8d5688e6c805: parsing go.mod:
#10 0.866 module declares its path as: abcde
#10 0.866 but was required as: github.com/bronger/abcde
因此,我在go.mod
中更正了模块名称并推送了结果。
最终,这样做是有效的。然而,在go get
最终检测到更改之前可能需要很长时间(30-60分钟)。最新的错误提交是8d5688e
,它也出现在上面的错误消息中。即使在GitHub上的最新提交是80c407b
之后的几分钟,go get
仍然抱怨8d5688e
。
为什么会这样呢?
英文:
I have created a Go module and put it at github.com/bronger/abcde
. Erroneously, I declared it in its go.mod
as module abcde
. Therefore, a go get github.com/bronger/abcde
in a Dockerfile (i.e. without my local copy of the program) fails with
#10 0.824 go: downloading github.com/bronger/abcde v0.0.0-20210813180406-8d5688e6c805 #10 0.866 go get: github.com/bronger/abcde@none updating to
#10 0.866 github.com/bronger/abcde@v0.0.0-20210813180406-8d5688e6c805: parsing go.mod:
#10 0.866 module declares its path as: abcde
#10 0.866 but was required as: github.com/bronger/abcde
So I corrected the module name in go.mod
and pushed the result.
Eventually, this works. However, it may take a long time (30–60 minutes) before go get
finally detects the change. The latest incorrect commit is 8d5688e
, which also occurs in the error message above. Even many minutes after 80c407b
is the latest commit on GitHub, go get
still complaints about 8d5688e
.
Why is this?
答案1
得分: 2
默认情况下,Go工具使用Go团队提供的代理。这意味着对模块的更改可以在一定时间内进行缓存。您可以在他们的网站上找到更多相关信息:https://proxy.golang.org/。
将GOPROXY=off
设置为环境变量将禁用使用该代理。
英文:
By default, the Go tools use a proxy provided by the Go Team. This means that changes to modules can be cached for a certain period. You'll be able to find more information about that on their website: https://proxy.golang.org/.
Setting GOPROXY=off
as an environment variable will disable the use of this proxy.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论