Go Version
- Go-Release-Cycle
- 一年两个版本 - 2 月,8 月
- bugfix backports 一个版本
- security backports 两个版本
- 参考
| ver | date | EOL | macOS | Windows |
|---|---|---|---|---|
| Go 1.26 | 2026-2 | 2027-02 | macOS 12+ | 移除 32-bit windows/arm |
| Go 1.25 | 2025-8 | 2026-08 | macOS 12+ | 最后包含 32-bit windows/arm |
| Go 1.24 | 2025-2 | 2026-02-10 | macOS 11+ | 32-bit windows/arm 标记 broken |
| Go 1.23 | 2024-8 | 2025-08-12 | macOS 11+ | |
| Go 1.22 | 2024-2 | 2025-02-11 | ||
| Go 1.21 | 2023-8 | 2024-08-13 | macOS 10.15+ | Windows 10+, Server 2016+ |
| Go 1.20 | 2023-2 | 2024-02-06 | macOS 10.13, 10.14 | Windows 7, 8, Server 2008, Server 2012 |
| Go 1.19 | 2022-8 | 2023-08-08 | - | - |
| Go 1.18 | 2022-3 | 2023-02-01 | - | 64-bit ARM |
| Go 1.17 | 2021-8 | 2022-08-02 | macOS 10.13 High Sierra | |
| Go 1.16 | 2021-2 | 2022-03-15 | - | |
| Go 1.15 | 2020-8 | 2021-08-16 | macOS 10.12 Sierra | |
| Go 1.14 | 2020-2 | 2021-02-16 | - | |
| Go 1.13 | 2019-8 | 2020-08-11 | macOS 10.11 El Capitan | Windows 7 |
| Go 1.12 | 2019-2 | 2020-02-25 | - | - |
| Go 1.11 | 2018-8 | 2019-09-03 | macOS 10.10 Yosemite | Windows 7/NT 4.0 |
| Go 1.10 | 2018-2 | 2019-02-25 | OS X 10.8, 10.9 | Windows XP/Vista |
- EOL 按官方 Release Policy 推算:每个大版本支持到后面两个大版本发布;未来版本 EOL 使用预计月份。
Roadmap
- 1.18 (2022-2) 会包含部分 generic
- 1.18 fuzz - https://go.dev/blog/fuzz-beta
Go 1.26
- 语言
new(expr):new可以直接接表达式并返回其地址,适合 optional pointer 字段初始化。- 泛型类型参数列表允许自引用约束,例如
type Adder[A Adder[A]] interface{ ... }。
- 工具链
go fix重做为 modernizers,基于go vet/analysis 框架,面向自动迁移到新语言和标准库惯用法。go mod init默认生成低一个 minor 的go版本,鼓励新模块兼容当前仍支持的 Go 版本。- 删除
cmd/doc与go tool doc,使用go doc。 pprof -http默认打开 flame graph 视图。
- Runtime/性能
- Green Tea GC 默认启用;Go 1.25 中为实验特性,目标是降低大量小对象场景的标记/扫描开销。
- cgo call 基线开销约降低 30%。
- 64-bit 平台 heap base address randomization,提升 cgo 相关内存利用漏洞的攻击难度。
- 实验性 goroutine leak profile:
GOEXPERIMENT=goroutineleakprofile,可通过 GC 可达性发现一类永久阻塞 goroutine。
- 标准库
- 新增
crypto/hpke,实现 RFC 9180 HPKE,包含后量子 hybrid KEM 支持。 - 实验性
simd/archsimd:GOEXPERIMENT=simd,amd64 架构专用 SIMD API。 - 实验性
runtime/secret:GOEXPERIMENT=runtimesecret,辅助清除处理 secret 时产生的临时值。 errors.AsType[T]:类型安全、泛型版errors.As。image/jpeg编解码器替换为更快、更准确实现;依赖 bit-for-bit 输出的测试可能需要更新。io.ReadAll降低中间分配,通常更快。log/slog.NewMultiHandler。net/http/httputil.ReverseProxy.Director废弃,推荐Rewrite,避免 hop-by-hop header 安全问题。testing.T/B/F.ArtifactDir配合go test -artifacts保存测试产物。
- 新增
- 安全/加密
- 新增抽象 KEM 接口
crypto.Encapsulator/crypto.Decapsulator。 crypto/*多处不再尊重传入的自定义随机源,改用安全随机;测试用testing/cryptotest.SetGlobalRandom。- TLS 默认启用更多后量子 hybrid key exchange;可用 GODEBUG 或
CurvePreferences关闭。
- 新增抽象 KEM 接口
- 平台
- Go 1.26 最后支持 macOS 12 Monterey;Go 1.27 将要求 macOS 13+。
- 移除 32-bit
windows/arm。 linux/riscv64支持 race detector。
- 升级关注
go fix自动现代化应先看 diff。- 依赖旧
go tool doc、旧 JPEG bitstream、旧 crypto 自定义随机源、ReverseProxyDirector的代码需要检查。 - 新 GC 默认启用,低延迟/GC-heavy 服务建议压测。
- 参考
Go 1.25
- 语言
- 没有影响程序的新语法;spec 中移除 core types 概念,改为专门文字描述。
- 工具链
go build -asan默认在退出时做 C allocation leak detection;可用ASAN_OPTIONS=detect_leaks=0关闭。- 发行包减少预构建 tool binary,非核心工具按需由
go tool构建运行。 go.mod新增ignoredirective:让go命令在匹配all、./...时忽略目录。go doc -http启动文档服务器。go version -m -json输出二进制内嵌runtime/debug.BuildInfo的 JSON。- 新增
workpackage pattern,匹配工作模块/工作区模块内所有包。 - 更新
goline 时不再自动加当前 toolchain line。 go vet新增waitgroup、hostportanalyzer。
- Runtime/性能
- container-aware
GOMAXPROCS:Linux 下默认考虑 cgroup CPU limit,并可周期更新;手动设置GOMAXPROCS后关闭。 - 实验性 Green Tea GC:
GOEXPERIMENT=greenteagc,目标降低 GC-heavy 程序 10–40% GC 开销。 runtime/trace.FlightRecorder:用内存环形缓冲捕获最近一段 trace,适合罕见事件。- 未处理 panic 的 recovered/repanicked 输出更简洁。
- Linux runtime 给 anonymous VMA 加用途名,方便内存分析。
- container-aware
- 编译器/链接器
- 修复 Go 1.21 引入的 nil pointer check 延迟 bug;错误检查前使用可能为 nil 的返回值会重新正确 panic。
- 默认 DWARF 5,降低 debug info 体积和链接时间;
GOEXPERIMENT=nodwarf5可回退。 - slice backing store 更多场景栈分配,可能暴露错误
unsafe.Pointer用法。
- 标准库
testing/synctest正式可用,用虚拟时间测试并发代码;Go 1.24 实验 API 将在 1.26 移除。- 实验性
encoding/json/v2和encoding/json/jsontext:GOEXPERIMENT=jsonv2。 sync.WaitGroup.Go简化启动并计数 goroutine。net/http.CrossOriginProtection:基于 Fetch metadata 的 CSRF 防护。os.Root、DirFS、CopyFS、testing/fstest.MapFS支持 symlink/io/fs.ReadLinkFS更完整。reflect.TypeAssert[T]减少Value.Interface().(T)分配。hash.Cloner、hash.XOF,标准 Hash 多数实现 Clone。testing.T/B/F.Attr和Output。log/slog.GroupAttrs、Record.Source。
- 安全/加密
- TLS 1.2 禁用 SHA-1 signature algorithms,
GODEBUG=tlssha1=1可临时回退。 - FIPS 模式下 ECDSA/Ed25519 signing 性能改善。
- RSA key generation 更快。
- TLS 1.2 禁用 SHA-1 signature algorithms,
- 平台
- macOS 12 Monterey+。
- 最后包含 broken 32-bit
windows/arm,Go 1.26 移除。 linux/loong64支持 race detector;linux/riscv64支持plugin。
- 升级关注
- 容器里 CPU limit 会影响默认
GOMAXPROCS,Kubernetes 服务需要重新看并发/吞吐指标。 -asan可能因 C leak 新增失败。sync.WaitGroup.Go可替换常见Add+go+Done模板,配合 vet 的waitgroup检查。json/v2仍是实验,不要无评估直接生产切换。
- 容器里 CPU limit 会影响默认
- 参考
Go 1.24
- 语言
- 完整支持泛型 type alias:
type Set[T comparable] = map[T]bool。 - 可用
GOEXPERIMENT=noaliastypeparams临时关闭;Go 1.25 起移除关闭开关。
- 完整支持泛型 type alias:
- 工具链
go.mod支持tooldirective,用于追踪可执行工具依赖,替代tools.go空导入惯例。go get -tool添加工具依赖;go tool可运行模块声明的工具。go get tool、go install tool可批量升级/安装当前模块工具。go build、go install支持-json结构化输出;go test -json也包含 build output/failure。- 新增
GOAUTH,用于私有模块获取认证。 go build会基于 VCS tag/commit 设置 main module version,dirty tree 加+dirty;-buildvcs=false关闭。GOCACHEPROG从实验转正,可外接构建/测试缓存程序。go vet新增testsanalyzer,并加强printf、buildtag、copylock检查。
- Runtime/性能
- 默认 map 实现切到 Swiss Tables,runtime 小对象分配、内部 mutex 等优化,整体 CPU overhead 平均下降。
- 可用
GOEXPERIMENT=noswissmap、nospinbitmutex回退相关实验实现。
- 标准库
os.Root/os.OpenRoot:限制在某目录内做文件系统操作,防 symlink/path traversal 逃逸。testing.B.Loop():替代for i := 0; i < b.N; i++,避免 benchmark body 被优化掉,也减少 setup/cleanup 误用。runtime.AddCleanup:比SetFinalizer更安全灵活的新 cleanup 机制。- 新增
weak包,提供 weak pointer;适合 cache、canonicalization map 等底层场景。 - 新增
crypto/mlkem,实现 ML-KEM/Kyber 后量子 KEM。 - 新增
crypto/hkdf、crypto/pbkdf2、crypto/sha3,从x/crypto进入标准库。 - FIPS 140-3 机制:
GOFIPS140、GODEBUG=fips140=...。 - 实验性
testing/synctest:GOEXPERIMENT=synctest,虚拟时间测试并发。 encoding/json增加omitzerotag,解决time.Time等零值与omitempty语义不一致问题。encoding.TextAppender/BinaryAppender,降低 marshal 分配。bytes、strings增加 iterator 版本:Lines、SplitSeq、FieldsSeq等。net/http增加Server.Protocols、Transport.Protocols、HTTP/2 配置与 h2c prior knowledge 支持。testing.T.Context、B.Context、T.Chdir、B.Chdir。sync.Map实现优化。
- 安全/加密
crypto/rand.Read保证不返回 error;底层失败时程序不可恢复崩溃。- RSA 小于 1024 bit 的 key 默认拒绝;
GODEBUG=rsa1024min=0临时回退。 crypto/tlsserver 支持 ECH;默认启用 X25519MLKEM768;移除旧X25519Kyber768Draft00。crypto/x509移除x509sha1,不再验证 SHA-1 证书签名。
- 平台
- Linux kernel 要求 3.2+。
- Go 1.24 是最后支持 macOS 11 Big Sur 的版本;Go 1.25 要求 macOS 12+。
- WASM 支持
//go:wasmexport,wasip1 可-buildmode=c-shared构建 reactor/library。 - 32-bit
windows/arm标记 broken。
- 升级关注
tooldirective 可以规范化项目工具依赖,建议替代tools.go。omitzero可用于 JSON API 中所有time.Time/业务零值字段。- TLS 后量子默认 key exchange 可能遇到旧服务器/中间设备兼容问题,可临时
GODEBUG=tlsmlkem=0。 math/rand.Seed顶层调用默认不再生效,需迁移到显式rand.New。
- 参考
Go 1.23
- 语言
for range支持 iterator function:func(func() bool)func(func(K) bool)func(func(K, V) bool)
- 泛型 type alias 预览:
GOEXPERIMENT=aliastypeparams,仅包内支持,跨包暂不支持。
- 工具链
- Go telemetry:默认 local,仅本地记录;
go telemetry on才会上报匿名统计。 go env -changed只输出与默认值不同的环境。go mod tidy -diff输出需要的 tidy diff,不修改文件,适合 CI 检查。go list -m -json增加Sum、GoModSum。go.mod/go.work新增godebugdirective。go vet新增stdversionanalyzer,检测当前go版本下过新的符号引用。- PGO 构建开销大幅降低;amd64/386 利用 PGO 做 hot block alignment。
- Go telemetry:默认 local,仅本地记录;
- Runtime/链接器
- 未处理 panic/fatal error 输出缩进调整,便于与 goroutine stack 区分。
- 局部变量栈槽可在不相交生命周期内复用,降低 stack 使用。
- 链接器限制新增
//go:linkname指向标准库 internal symbol;可用-checklinkname=0调试回退。
- 标准库
- Timer/Ticker 重大语义修正:未 stop 的 timer/ticker 可被 GC;timer channel 改为同步无缓冲,
Stop/Reset后不再收到旧值。仅go 1.23+模块默认启用;GODEBUG=asynctimerchan=1回退。 - 新增
unique包:对 comparable 值做 canonicalization/interning,返回可快速比较的Handle[T]。 - 新增
iter包;slices、maps增加 iterator 辅助:All、Values、Collect、Sorted、Chunk等。 - 新增
structs.HostLayout,标记与 host platform 布局兼容的结构体。 encoding/binary.Encode、Decode、Append。go/ast.Preorder、go/typesalias/generic alias 支持增强。net.KeepAliveConfig、TCPConn.SetKeepAliveConfig。net/http增加 cookie parsing、Request.Pattern、NewRequestWithContext等;ServeContent/ServeFile错误响应会移除内容相关 header。os.CopyFS;Linux pidfd 支持;Windows symlink/reparse point 行为修正。filepath.Localize。reflect.Value.Seq/Seq2、Type.CanSeq/CanSeq2。runtime/debug.SetCrashOutput。sync.Map.Clear。sync/atomic增加And/Or。- Windows timer resolution 改善到约 0.5ms。
- Timer/Ticker 重大语义修正:未 stop 的 timer/ticker 可被 GC;timer channel 改为同步无缓冲,
- 安全/加密
- TLS client 支持 ECH draft。
- 默认移除 3DES cipher suites,可用
GODEBUG=tls3des=1回退。 - 默认启用实验性 X25519Kyber768Draft00,可用
GODEBUG=tlskyber=0回退。 x509sha1将在 Go 1.24 移除。
- 平台
- macOS 11 Big Sur+。
- Go 1.23 是最后支持 Linux kernel 2.6.32+ 的版本;Go 1.24 要求 3.2+。
- 新增
GOARM64、GORISCV64。 - OpenBSD/riscv64 实验支持。
- 升级关注
- Timer/Ticker 语义变化是 1.23 最容易影响行为的点,尤其是依赖
len(timer.C)或旧Reset/Stop模式的代码。 stdversion能补强多 Go 版本库的 CI。iter/slices/maps开始形成新集合遍历风格,但公共 API 暴露 iterator 前要考虑使用方最低 Go 版本。
- Timer/Ticker 语义变化是 1.23 最容易影响行为的点,尤其是依赖
- 参考
Go 1.22
Go 1.21
- GOOS=wasip1, GOARCH=wasm
go:wasmimport支持 import wasm 的函数
- 增加内置函数 min, max, clear
- GOEXPERIMENT=loopvar
- for loop 的变量作用范围从 loop 变为 iteration - 也就是说每次循环的变量不会变了
go build -gcflags=all=-d=loopvar=2 cmd/go检测受影响的地方- https://tip.golang.org/wiki/LoopvarExperiment
- panic recover 不再会返回 nil
- nil 会转为
*runtime.PanicNilError GODEBUG=panicnil=1恢复以前的行为
- nil 会转为
- 新增
log/slog结构化日志 - 新增
testing/slogtest - 新增
slices,maps,cmp - https://go.dev/doc/toolchain
- GOTOOLCHAIN
- 参考
Go 1.20
- slice -> array pointer -
[4]byte(x)->*(*[4]byte)(x) - 参考
Go 1.19
fmt.FormatString(State)- #51668fmt.Append,fmt.Appendf,fmt.Appendlnflag.TextVar- 使用encoding.TextUnmarshaler解析 - 例如:big.Int,net.IP,time.Timestrings.CutPrefix,strings.CutSuffix- #42537- 移除前缀后缀
url.JoinPathtime.Duration.Abs()http.MaxByteErroratomic.Pointer[T]- 第一个在 std 库中使用 generic 的方法runtime/debug.SetMemoryLimit-GOMEMLIMIT- 更好避免 OOMsort.Find-sort.Sort- pattern defeating quicksort https://arxiv.org/pdf/2106.05123.pdf
- 支持 龙芯 - linux/loong64
//go:build支持 unix -> aix, android, darwin, dragonfly, freebsd, hurd, illumos, ios, linux, netbsd, openbsd, solaris- 参考
Go 1.18
- generic
- 支持类型参数
- stdlib 这个版本不变
- constraints -> golang.org/x/exp/constraints
- 暂时还有异议,不添加到 std
- golang.org/x/exp/slices
- golang.org/x/exp/maps
- 限制 - 可能 Go 1.19 移除
- 不支持方法或函数内定义 范型
- 不支持 real, imag, complex
- 不支持 struct field
- type alias 不允许 范型
- 限制
- 不允许内嵌 类型参数、指针 到 类型参数 作为匿名字段
func Forbit[M any, PT interface {*M}]()- https://stackoverflow.com/questions/71440697
- union element with more than one term may not contain an interface type with a non-empty method set
- 不允许内嵌 类型参数、指针 到 类型参数 作为匿名字段
- why use bracket
- 新增 workspace 工作模式 - Proposal: Multi-Module Workspaces in cmd/go
- 新增 go.work 配置文件 - -workfile
- go.work.sum
- 新增 GOWORK 环境变量
- 新增 go.work 配置文件 - -workfile
- 新增 fuzzing 测试 - https://go.dev/doc/fuzz/
- 新包
- debug/buildinfo - 内置 VCS 版本信息 -
- 新增 GOVCS 环境变量
- 减少使用 -X 场景
- 构建重现
- Settings
- vsc.modified=true - dirty
- vsc.time
- vsc.revision=SHA256
- vsc=git
- 不会包含 Tag 信息
- 因为 tag 可修改
- tag 可指向多个 - 不可复现
- net/netip
- debug/buildinfo - 内置 VCS 版本信息 -
- 包变化
- runtime/debug.BuildInfo 增加 GoVersion, Settings
- testing.F - fuzzing
- Ports
- 新增 GOAMD64 环境变量 - 默认 v1
- 参考
- https://tip.golang.org/doc/go1.18
- GoLand Generics support - 2022.1 GO-9515
- GoLand Support Go workspaces - 2022.1 GO-12167
| env | mean |
|---|---|
GOVCS=github.com:git,evil.com:off,\*:gi|hg | 部分允许 VCS |
GOVCS=*:all | 所有允许 VCS |
GOVCS=*:off | 关闭 VCS |
go work init ./mod ./tools
go work sync
go.work
go 1.17
use (
./mod // golang.org/x/mod
./tools // golang.org/x/tools
)
replace golang.org/x/net => example.com/fork/net v1.4.5
Go 1.17
- go.mod
- 支持 lazy 模块
- 支持
//Deprecated:废弃
&T[N]转*[N]T- slice 转数组指针 - 长度不够则panicunsafe.Add(ptr, len)- 指针运算unsafe.Slice(ptr, len)- 指针*T转 slice[]T// +build->//go:build- go run 支持版本 -
go run example.com/[email protected] runtime/cgo.Handle- cgo 和 go 互转- 如果 go 版本不同 vendor/modules.txt 会记录版本
- arch
- macOS 10.13 High Sierra
- windows/arm64
- openbsd/mips64 cgo
- go1.17
- time
- 新增 time.UnixMills - 比较好用 - 等同 JS 和 Java 里的 时间戳
# 升级 go.mod
go mod tidy -go=1.17
# 降级兼容
go mod tidy -compat=1.17
Go 1.16
- 支持嵌入文件
go:embed - 新增 io/fs 包
- 废弃大量 ioutil 方法,移到 io 和 os 包
- arch
- macOS 10.12 Sierra
- 支持 darwin/amd64
- iOS 重命名为 ios/arm64 - 之前是 darwin/amd64
- ios/amd64 - 用于 iOS 模拟器
- 支持 netbsd/arm64
- openbsd/mips64 - 不支持 cgo
- linux/riscv64 支持 cgo, pie
- 移除 GO386=387, 使用 GO386=softfloat 支持 non-SSE2
- GOVCS
- go list -
go list -exported -f {{.Export}} - windows
go build -buildmode=c-shared生产 Windows ASLR DLLs- 可通过
--ldflags=-aslr=false关闭
- 可通过
- 包
- os
- os.DirEntry -> fs.DirEntry
- os.DirFS -> fs.FS
- 增加辅助目录扫描的方法
- os
Go 1.15
- 较多优化
- 支持转 unsafe.Pointer 为 uintptr
- 废弃 X.509 CommonName - 临时方案 x509ignoreCN=0
- arch
- 停止 darwin/386
- 停止 darwin/arm
- windows
- ASLR -buildmode=pie
- Ctrl-C 不再退出 DLL
Go 1.14
- go module 稳定
- Permit embedding of interfaces with overlapping method sets
- 新增 hash/maphash - 将 bytes 和 string hash 为 int - 用于实现 hash table
- arch
- 停止 nacl 支持
// 允许重复方法
type ReadWriteCloser interface {
io.ReadCloser
io.WriteCloser
}
Go 1.13
- 支持 0b,0B 表示二进制
- 支持 0o,0O 表示八进制
- 0x 支持浮点数
0x1.0p-1021 - 支持下划线分割数字
1_000 - shift count 不在要求是 unsigned
- go build -trimpath - 移除构建绝对路径, 用于支持可复现构建
go build -o bin/ ./cmd/...- 目录构建多个输出- GOPROXY, GOPRIVATE
- sql.NullTime
- errors.Unwrap, errors.Is, errors.As
- TLS 1.3
Go 1.12
- arch
- linux/ppc64 cgo
- windows/arm
Go 1.11
- arch
- js/wasm
Go 1.7
- context - https://golang.org/pkg/context