Compare commits

...

2 Commits

Author SHA1 Message Date
6a2e8e1193 Merge branch 'main' of gitea.icodef.com:codfrm/blog
All checks were successful
Release / deploy (push) Successful in 2m52s
2025-07-01 08:17:01 +08:00
a5cca0dee0 golang changelog 2025-07-01 08:15:44 +08:00

View File

@ -1,4 +1,5 @@
# Golang 版本变化 # Golang 版本变化
> [Release History](https://tip.golang.org/doc/devel/release) > [Release History](https://tip.golang.org/doc/devel/release)
持续更新golang版本更新变化内容只记录了一些值得关注的内容内容做了很大的精简仅做知识索引。 持续更新golang版本更新变化内容只记录了一些值得关注的内容内容做了很大的精简仅做知识索引。
@ -9,7 +10,41 @@
某些变更知道后还是挺有用的,例如我之前遇到过一个随机数的问题,本地没问题,线上总是生成一样的随机数, 某些变更知道后还是挺有用的,例如我之前遇到过一个随机数的问题,本地没问题,线上总是生成一样的随机数,
排查了一段时间才知道是因为没有设置随机数种子我本地用的是go1.20线上是go1.19在1.20版本时,会自动生成一个随机数种子。 排查了一段时间才知道是因为没有设置随机数种子我本地用的是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 ## 1.22
> [Go 1.22 Release Notes](https://tip.golang.org/doc/go1.22) > [Go 1.22 Release Notes](https://tip.golang.org/doc/go1.22)
- 💥 `for range`不再是共享变量 这个变更可能会导致一些代码的行为发生变化 - 💥 `for range`不再是共享变量 这个变更可能会导致一些代码的行为发生变化
@ -18,6 +53,7 @@
-`http.ServeMux`路由增强 -`http.ServeMux`路由增强
## 1.21 ## 1.21
> [Go 1.21 Release Notes](https://tip.golang.org/doc/go1.21) > [Go 1.21 Release Notes](https://tip.golang.org/doc/go1.21)
- 🔥 不再支持Windows 7 - 🔥 不再支持Windows 7
@ -29,6 +65,7 @@
-`context`包新增WithoutCancel、WithDeadlineCause、WithTimeoutCause函数 -`context`包新增WithoutCancel、WithDeadlineCause、WithTimeoutCause函数
## 1.20 ## 1.20
> [Go 1.20 Release Notes](https://tip.golang.org/doc/go1.20) > [Go 1.20 Release Notes](https://tip.golang.org/doc/go1.20)
- 💥 引入PGOProfile-guided optimization - 💥 引入PGOProfile-guided optimization
@ -38,6 +75,7 @@
- ✨ 新增`arena`包、`math/rand`自动全局随机数 - ✨ 新增`arena`包、`math/rand`自动全局随机数
## 1.19 ## 1.19
> [Go 1.19 Release Notes](https://tip.golang.org/doc/go1.19) > [Go 1.19 Release Notes](https://tip.golang.org/doc/go1.19)
- 💥 新的内存模型 - 💥 新的内存模型