Go Version
- Go-Release-Cycle
- 一年两个版本 - 2 月,8 月
- bugfix backports 一个版本
- security backports 两个版本
- 参考
| ver | date | macOS | Windows |
|---|---|---|---|
| Go 1.25 | 2025-8 | ||
| Go 1.24 | 2025-2 | ||
| Go 1.23 | 2024-8 | ||
| Go 1.22 | 2024-2 | ||
| Go 1.21 | 2023-8 | macOS 10.15+ | Windows 10+, Server 2016+ |
| Go 1.20 | 2023-2 | macOS 10.13, 10.14 | Windows 7, 8, Server 2008, Server 2012 |
| Go 1.19 | 2022-8 | - | - |
| Go 1.18 | 2022-3 | - | 64-bit ARM |
| Go 1.17 | 2021-8 | macOS 10.13 High Sierra | |
| Go 1.16 | 2021-2 | - | |
| Go 1.15 | 2020-8 | macOS 10.12 Sierra | |
| Go 1.14 | 2020-2 | - | |
| Go 1.13 | 2019-8 | macOS 10.11 El Capitan | Windows 7 |
| Go 1.12 | 2019-2 | - | - |
| Go 1.11 | 2018-8 | macOS 10.10 Yosemite | Windows 7/NT 4.0 |
| Go 1.10 | 2018-2 | OS X 10.8, 10.9 | Windows XP/Vista |
Roadmap
- 1.18 (2022-2) 会包含部分 generic
- 1.18 fuzz - https://go.dev/blog/fuzz-beta
Go 1.25
Go 1.24
Go 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