golang.org软件包和标准库之间的区别 [英] Difference between golang.org packages and the standard library

查看:131
本文介绍了golang.org软件包和标准库之间的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用go已有很短的时间了,并且我注意到Go(标准库)和golang.org/x/之间存在重复的软件包.

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 net/html
  • golang.org/x/crypto crypto
  • 也许还有我现在不记得的更多...

推荐答案

https://golang.org/pkg/#subrepo

这些软件包是Go项目的一部分,但在主Go树之外.它们是在比Go核心更宽松的兼容性要求下开发的.

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.

使用标准库软件包,除非您非常需要使用/x/变体,并且可以承受破坏更改的风险.

Use the standard library packages unless you have a strong need to use the /x/ variant and can accept the risk of breaking changes.

这篇关于golang.org软件包和标准库之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆