英文:
Difference between golang.org packages and the standard library
问题
我现在是你的中文翻译。以下是你要翻译的内容:
我最近开始使用Go语言,注意到在Go(标准库)和golang.org/x/之间存在重复的包。
我的问题是:为什么它们会发布两次?在这两个中,我应该使用哪一个(更更新、更规范等)?
到目前为止,我注意到一些重复发布的示例包括:
golang.org/x/net/html
和net/html
golang.org/x/crypto
和crypto
- 还可能有其他我现在记不起来的...
英文:
I've been using go for a short time now, and I've been noticing that there are duplicate packages between Go (standard library) and golang.org/x/.
My questions are: Why are they released twice? And of the two, which one should I use (more up-to-date, canonical, etc)?
Some sample packages that are released twice that I've noticed so far:
golang.org/x/net/html
vsnet/html
golang.org/x/crypto
vscrypto
- and maybe more that I can't remember right now...
答案1
得分: 5
这些包是Go项目的一部分,但不属于主要的Go树。它们的开发比Go核心要求更宽松。
除非你有强烈的需求使用/x/
变体并且可以接受破坏性变更的风险,否则请使用标准库的包。
英文:
https://golang.org/pkg/#subrepo
> These packages are part of the Go Project but outside the main Go tree.
> They are developed under looser compatibility requirements than the Go core.
Use the standard library packages unless you have a strong need to use the /x/
variant and can accept the risk of breaking changes.
答案2
得分: 5
golang.org/x/
命名空间中的许多包以前只存在于那里,后来被纳入了标准库。为了向后兼容,golang.org/x/
版本仍然存在。
然而,新的应用程序应该始终使用标准库版本,除非有充分的理由不这样做(比如使用仍然使用旧版本的库)。
英文:
Many of the packages in the golang.org/x/
namespace used to live only there, then were later adopted into the standard library. For backward compatibility, the golang.org/x/
version remains.
New apps should always use the standard library version, though, unless there's a compelling reason otherwise (such as using a library that still uses the old version).
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论