如果指向本地模块,应该提交替换指令吗?

发布于 2025-02-06 19:37:59 字数 1455 浏览 1 评论 0原文

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

沉溺在你眼里的海 2025-02-13 19:37:59

简而言之,只要您也将其重定向的内容提交替换。我们经常这样做以在推到GitHub之前在本地处理包裹。如果您修改了开源软件包,但不想共享更改,也可以使用它。

最初,替换的常见用途是用于临时测试或尝试替代版本的软件包。但是许多人意外地使用了go.mod使用临时替换子句,因此这就是为什么go 1.18介绍了工作空间文件的原因。

因此,请使用工作区进行本地临时实验。使用替换(半)永久重定向。始终提交您的go.mod文件,但永远不要提交工作区文件。

这是我的理解。我敢肯定,如果我错了,我会纠正我。

In brief you can commit the replace as long as you also commit the things it is redirecting to. We often do this to work on a package locally before pushing to github. You might also use it if you have modified an open source package but don't want to share the changes.

Originally, a common use for replace was for temporarily testing or trying an alternative version of a package. But many people were accidentally committing go.mod with the temporary replace clause so that is why Go 1.18 introduced the workspace file.

So use workspace for local temporary experiments. Use replace for (semi)permanent redirection. Always commit your go.mod file but never commit the workspace file.

This is my understanding. I'm sure someone will correct me if I'm wrong.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文