Compare commits
2 Commits
84bcc1ecb7
...
main
Author | SHA1 | Date | |
---|---|---|---|
6a2e8e1193 | |||
a5cca0dee0 |
@ -1,4 +1,5 @@
|
||||
# Golang 版本变化
|
||||
|
||||
> [Release History](https://tip.golang.org/doc/devel/release)
|
||||
|
||||
持续更新golang版本更新变化内容,只记录了一些值得关注的内容,内容做了很大的精简,仅做知识索引。
|
||||
@ -9,7 +10,41 @@
|
||||
某些变更知道后还是挺有用的,例如我之前遇到过一个随机数的问题,本地没问题,线上总是生成一样的随机数,
|
||||
排查了一段时间,才知道是因为没有设置随机数种子,我本地用的是go1.20,线上是go1.19,在1.20版本时,会自动生成一个随机数种子。
|
||||
|
||||
## 1.24
|
||||
|
||||
> [Go 1.24 Release Notes](https://tip.golang.org/doc/go1.24)
|
||||
|
||||
- 🔥 要求Linux内核3.2+ 不再支持Linux内核2.6.32
|
||||
- 🔥 macOS支持变更 最后支持macOS 11 Big Sur的版本,1.25将要求macOS 12+
|
||||
- 💥 完全支持泛型类型别名 类型别名现在可以像定义类型一样进行参数化
|
||||
- 💥 移除SHA-1证书签名支持 `crypto/x509`不再支持SHA-1签名验证
|
||||
- 💥 RSA密钥最小长度要求1024位 小于1024位的RSA密钥将返回错误
|
||||
- ✨ 新增`os.Root`类型 提供目录限制的文件系统访问
|
||||
- ✨ 新增`testing.B.Loop`方法 更快且不易出错的基准测试迭代方法
|
||||
- ✨ 新增`runtime.AddCleanup`函数 比`SetFinalizer`更灵活高效的终结器机制
|
||||
- ✨ 新增`weak`包 提供弱指针支持
|
||||
- ✨ 新增`crypto/mlkem`包 实现ML-KEM-768和ML-KEM-1024后量子密钥交换
|
||||
- ✨ 新增`crypto/hkdf`、`crypto/pbkdf2`、`crypto/sha3`包 从golang.org/x/crypto迁移
|
||||
- ✨ 新增实验性`testing/synctest`包 支持并发代码测试
|
||||
- ✨ JSON支持`omitzero`标签 比`omitempty`更清晰地省略零值
|
||||
- ⚡️ 运行时性能提升2-3% 包括基于Swiss Tables的新map实现、更高效的小对象内存分配等
|
||||
|
||||
## 1.23
|
||||
|
||||
> [Go 1.23 Release Notes](https://tip.golang.org/doc/go1.23)
|
||||
|
||||
- 💥 `for range`支持迭代器函数 支持`func(func() bool)`、`func(func(K) bool)`、`func(func(K, V) bool)`类型的迭代器
|
||||
- 💥 Timer和Ticker的重大变化
|
||||
- 未引用的Timer/Ticker可立即被垃圾回收,即使未调用Stop方法
|
||||
- timer channel变为无缓冲(容量0),保证Reset/Stop调用后不会收到过期值
|
||||
- ✨ 新增`iter`包 提供用户定义迭代器的基本定义
|
||||
- ✨ 新增`unique`包 提供值规范化功能(类似"interning"或"hash-consing")
|
||||
- ✨ 新增`structs`包 提供修改结构体属性的类型,如`HostLayout`标记符合主机平台期望的结构体布局
|
||||
- ✨ `slices`包新增多个迭代器相关函数 如`All`、`Values`、`Backward`、`Collect`、`Sorted`、`Chunk`等
|
||||
- ✨ `maps`包新增多个迭代器相关函数 如`All`、`Keys`、`Values`、`Insert`、`Collect`等
|
||||
|
||||
## 1.22
|
||||
|
||||
> [Go 1.22 Release Notes](https://tip.golang.org/doc/go1.22)
|
||||
|
||||
- 💥 `for range`不再是共享变量 这个变更可能会导致一些代码的行为发生变化
|
||||
@ -18,6 +53,7 @@
|
||||
- ✨ `http.ServeMux`路由增强
|
||||
|
||||
## 1.21
|
||||
|
||||
> [Go 1.21 Release Notes](https://tip.golang.org/doc/go1.21)
|
||||
|
||||
- 🔥 不再支持Windows 7
|
||||
@ -29,6 +65,7 @@
|
||||
- ✨ `context`包新增WithoutCancel、WithDeadlineCause、WithTimeoutCause函数
|
||||
|
||||
## 1.20
|
||||
|
||||
> [Go 1.20 Release Notes](https://tip.golang.org/doc/go1.20)
|
||||
|
||||
- 💥 引入PGO(Profile-guided optimization)
|
||||
@ -38,6 +75,7 @@
|
||||
- ✨ 新增`arena`包、`math/rand`自动全局随机数
|
||||
|
||||
## 1.19
|
||||
|
||||
> [Go 1.19 Release Notes](https://tip.golang.org/doc/go1.19)
|
||||
|
||||
- 💥 新的内存模型
|
||||
|
Reference in New Issue
Block a user