关于golang:Go-的-golangorgx-系列包和标准库包有什么区别

8次阅读

共计 746 个字符,预计需要花费 2 分钟才能阅读完成。

在开发过程中可能会遇到这样的状况,有一些包是引入自不同中央的,比方:

  • golang.org/x/net/htmlnet/html
  • golang.org/x/cryptocrypto

那这是什么起因呢?

援用 Go 官网 Wiki 的说法:

The golang.org/x/… repositories are part of the Go Project but outside the main Go tree.

They are developed under looser compatibility requirements than the Go core. In general, they will support the previous two releases and tip.

大略意思就是,Go 规范库的包对向前兼容性有严格的规范。尽管 golang.org/x/... 系列包也是 Go 我的项目的一部分,然而在比 Go 规范库包更宽松的兼容性规范下开发,个别它们反对向前兼容两个版本。

golang.org/x/... 为官网的辅助包,是一种具备官网试验性质的包, 也就是说不排除有 BUG,或者可能健壮性不是特地好;正式的规范库是有保障的包,前者有些成熟的性能会缓缓的放到规范库包里。

激情举荐:

  • 技术博客: 硬核后端技术干货,内容包含 Python、Django、Docker、Go、Redis、ElasticSearch、Kafka、Linux 等。
  • Go 程序员: Go 学习路线图,包含根底专栏,进阶专栏,源码浏览,实战开发,面试刷题,必读书单等一系列资源。
  • 面试题汇总: 包含 Python、Go、Redis、MySQL、Kafka、数据结构、算法、编程、网络等各种常考题。

参考:

  • https://github.com/golang/go/wiki/X-Repositories
正文完
 0