DRAFT RELEASE NOTES — Introduction to Go 1.22

Go 1.22 is not yet released. These are work-in-progress release notes. Go 1.22 is expected to be released in February 2024.

Changes to the language

TODO: complete this section

Tools

Go command

Cgo

Vet

TODO: https://go.dev/cl/539016: go/analysis/passes/loopclosure: disable checker after go1.22.; loopclosure was modified to only not report in files with GoVersion after 1.22.

Runtime

The runtime now keeps type-based garbage collection metadata nearer to each heap object, improving the CPU performance (latency or throughput) of Go programs by 1—3%. This change also reduces the memory overhead of the majority Go programs by approximately 1% by deduplicating redundant metadata. Some programs may see a smaller improvement because this change adjusts the size class boundaries of the memory allocator, so some objects may be moved up a size class.
A consequence of this change is that some objects' addresses that were previously always aligned to a 16 byte (or higher) boundary will now only be aligned to an 8 byte boundary. Some programs that use assembly instructions that require memory addresses to be more than 8-byte aligned and rely on the memory allocator's previous alignment behavior may break, but we expect such programs to be rare. Such programs may be built with GOEXPERIMENT=noallocheaders to revert to the old metadata layout and restore the previous alignment behavior, but package owners should update their assembly code to avoid the alignment assumption, as this workaround will be removed in a future release.

Compiler

TODO: complete this section, or delete if not needed

Linker

TODO: https://go.dev/issue/62577: cmd/link, cmd/go: emit split DWARF on darwin

TODO: complete this section, or delete if not needed

Bootstrap

As mentioned in the Go 1.20 release notes, Go 1.22 now requires the final point release of Go 1.20 or later for bootstrap. We expect that Go 1.24 will require the final point release of Go 1.22 or later for bootstrap.

Core library

New math/rand/v2 package

TODO: https://go.dev/cl/502495: math/rand/v2: start of new API; modified api/next/61716.txt

TODO: https://go.dev/cl/502497: math/rand/v2: remove Read; modified api/next/61716.txt

TODO: https://go.dev/cl/502498: math/rand/v2: remove Rand.Seed; modified api/next/61716.txt

TODO: https://go.dev/cl/502499: math/rand/v2: change Source to use uint64; modified api/next/61716.txt

TODO: https://go.dev/cl/502500: math/rand/v2: add, optimize N, UintN, Uint32N, Uint64N; modified api/next/61716.txt

TODO: https://go.dev/cl/502505: math/rand/v2: add PCG-DXSM; modified api/next/61716.txt

TODO: https://go.dev/cl/502506: math/rand/v2: delete Mitchell/Reeds source; modified api/next/61716.txt

TODO: https://go.dev/cl/516857: math/rand/v2: rename various functions; modified api/next/61716.txt

TODO: https://go.dev/cl/516859: math/rand/v2: add ChaCha8; modified api/next/61716.txt

Minor changes to the library

As always, there are various minor changes and updates to the library, made with the Go 1 promise of compatibility in mind. There are also various performance improvements, not enumerated here.

TODO: complete this section

archive/tar

TODO: https://go.dev/issue/50102: add FileInfoNames interface

TODO: https://go.dev/issue/58000: add (*Writer).AddFS

TODO: https://go.dev/cl/513316: archive/tar: add AddFS method to Writer; modified api/next/58000.txt

TODO: https://go.dev/cl/514235: archive/tar: add FileInfoNames interface; modified api/next/50102.txt

bufio

TODO: https://go.dev/issue/56381: allow terminating Scanner early cleanly without a final token or an error

cmd

TODO: https://go.dev/cl/498416: cmd: add a new analyzer for check missing values after append

cmp

TODO: https://go.dev/issue/60204: add Or

TODO: https://go.dev/cl/504883: cmp: add Or; modified api/next/60204.txt

crypto/tls

TODO: https://go.dev/issue/43922: implement RFC7627

TODO: https://go.dev/issue/60107: QUIC 0-RTT APIs

TODO: https://go.dev/issue/62459: make default minimum version for servers TLS 1.2

TODO: https://go.dev/issue/63413: disable RSA key exchange cipher suites by default

TODO: https://go.dev/cl/514997: crypto/tls: change SendSessionTicket to take an options struct; modified api/go1.21.txt

TODO: https://go.dev/cl/541516: crypto/tls: change default minimum version to 1.2

TODO: https://go.dev/cl/541517: crypto/tls: remove RSA KEX ciphers from the default list

TODO: https://go.dev/cl/544155: crypto/tls: disable ExportKeyingMaterial without EMS

crypto/x509

TODO: https://go.dev/issue/57178: support code-constrained roots

TODO: https://go.dev/issue/58922: add android user trusted CA folder as a possible source for certificate retrieval

TODO: https://go.dev/issue/60665: introduce new robust OID type & use it for certificate policies

TODO: https://go.dev/cl/519315: crypto/x509: implement AddCertWithConstraint; modified api/next/57178.txt

TODO: https://go.dev/cl/520535: crypto/x509: add new OID type and use it in Certificate; modified api/next/60665.txt

database/sql

The new Null[T] type provide a way to scan nullable columns for any column types.

encoding

TODO: https://go.dev/issue/53693: provide append-like variants

TODO: https://go.dev/cl/504884: encoding: add AppendEncode and AppendDecode; modified api/next/53693.txt

TODO: https://go.dev/cl/505236: encoding: reject negative runes in Encoding.WithPadding; Providing a negative rune to Encoding.WithPadding other than NoPadding made no semantic sense, and will now panic.

go/ast

TODO: https://go.dev/issue/52463: formally deprecate Object

TODO: https://go.dev/cl/504915: go/ast: deprecate Object; modified api/go1.21.txt

go/types

TODO: https://go.dev/issue/62037: add Info.PkgName method

TODO: https://go.dev/issue/62605: Export Info.FileVersions for access to file-specific version information

TODO: https://go.dev/issue/63223: API changes to support explicit Alias nodes

TODO: https://go.dev/cl/540056: go/types: export Info.FileVersions; modified api/next/62605.txt

TODO: https://go.dev/issue/61035: go/types, types2: fix SizesFor("gc", ...) to match actual gc behavior

TODO: https://go.dev/cl/541575: go/types, types2: implement Info.PkgNameOf; modified api/next/62037.txt

TODO: https://go.dev/cl/541737: go/types, types2: implement Alias proposal (export API); modified api/next/63223.txt

go/version

TODO: https://go.dev/issue/62039: package for handling Go version strings

TODO: https://go.dev/cl/538895: go/version: add new package; modified api/next/62039.txt

html/template

TODO: https://go.dev/issue/61619: allow actions in JS template literals

TODO: https://go.dev/cl/507995: html/template: support parsing complex JS template literals; modified api/next/61619.txt

io

TODO: https://go.dev/issue/61870: add SectionReader.Outer method

TODO: https://go.dev/cl/526855: io: add (*SectionReader).Outer(); modified api/next/61870.txt

log/slog

TODO: https://go.dev/issue/62418: enable setting level on default log.Logger

TODO: https://go.dev/cl/525096: log/slog: add LogLoggerLevel to enable setting level on the default logger; modified api/next/62418.txt

math/big

TODO: https://go.dev/issue/50489: Rat: add FloatPrec() (int, bool)

TODO: https://go.dev/cl/539299: math/big: implement Rat.FloatPrec; modified api/next/50489.txt

net

TODO: https://go.dev/issue/58808: arrange zero-copy of os.File and TCPConn to UnixConn

TODO: https://go.dev/cl/467335: net: respect hosts file when resolving names for Windows

net/http

TODO: https://go.dev/issue/51971: add ServeFileFS, FileServerFS, NewFileTransportFS

TODO: https://go.dev/issue/61410: enhanced ServeMux routing

TODO: https://go.dev/cl/513956: net/http: add ServeFileFS, FileServerFS, NewFileTransportFS; modified api/next/51971.txt

TODO: https://go.dev/cl/517336: net/http: disallow empty Content-Length header

TODO: https://go.dev/cl/528355: net/http: implement path value methods on Request; modified api/next/61410.txt

net/http/cgi

TODO: https://go.dev/cl/539615: net/http/cgi: the PATH_INFO should be empty or start with a slash

net/netip

TODO: https://go.dev/issue/61642: add Prefix.Compare and AddrPort.Compare

TODO: https://go.dev/cl/524616: net/netip: add AddrPort.Compare and Prefix.Compare; modified api/next/61642.txt

os

TODO: https://go.dev/cl/516555: os: follow all name surrogate reparse points in Stat on Windows

TODO: https://go.dev/issue/58808: arrange zero-copy of os.File and TCPConn to UnixConn

os/exec

TODO: https://go.dev/cl/528037: os/exec: fix edge cases in Windows PATH resolution

TODO: https://go.dev/cl/528038: os/exec: avoid calling LookPath in cmd.Start for resolved paths

go/types

The start position (Pos) of the lexical environment block (Scope) that represents a function body has changed: it used to start at the opening curly brace of the function body, but now starts at the function's func token.

reflect

The Value.IsZero method will now return true for a floating-point or complex negative zero, and will return true for a struct value if a blank field (a field named _) somehow has a non-zero value. These changes make IsZero consistent with comparing a value to zero using the language == operator.

runtime

TODO: https://go.dev/issue/61015: change mutex profile to scale contention by number of blocked goroutines

runtime/metrics

TODO: https://go.dev/issue/63340: provide histogram of all STW events

slices

The new function Concat concatenates multiple slices.

Functions that shrink the size of a slice (Delete, DeleteFunc, Compact, CompactFunc, and Replace) now zero the elements between the new length and the old length.

Insert now always panics if the argument i is out of range. Previously it did not panic in this situation if there were no elements to be inserted.

syscall

TODO: https://go.dev/issue/60797: undeprecate

TODO: https://go.dev/cl/520266: syscall: add support to get pidfd from ForkExec on Linux

TODO: https://go.dev/cl/541015: syscall: support O_SYNC flag for os.OpenFile on windows

testing/slogtest

TODO: https://go.dev/issue/61758: support sub-tests

TODO: https://go.dev/cl/516076: testing/slogtest: add Run to run cases as subtests; modified api/next/61758.txt

Ports

Arm

The GOARM environment variable now allows you to select whether to use software or hardware floating point. Previously, valid GOARM values were 5, 6, or 7. Now those same values can be optionally followed by ,softfloat or ,hardfloat to select the floating-point implementation.

This new option defaults to softfloat for version 5 and hardfloat for versions 6 and 7.

TODO: https://go.dev/cl/481315: runtime, cmd/go: enable memory sanitizer on linux/loong64

TODO: https://go.dev/cl/517935: cmd/dist,internal/platform: enable openbsd/ppc64 port

TODO: https://go.dev/cl/537615: debug/elf,cmd/link: add additional relocations for loong64; modified api/next/63725.txt

TODO: https://go.dev/cl/469395: debug/elf,cmd/link: add additional MIPS64 relocation type; modified api/next/61974.txt