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.
TODO: complete this section
The trace tool's web UI has been gently refreshed as part of the
work to support the new tracer, resolving several issues and improving the
readability of various sub-pages.
The web UI now supports exploring traces in a thread-oriented view.
The trace viewer also now displays the full duration of all system calls.
These improvements only apply for viewing traces produced by programs built with
Go 1.22 or newer.
A future release will bring some of these improvements to traces produced by older
version of Go.
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.
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.
TODO: complete this section.
Profile-guided Optimization (PGO) builds can now devirtualize a higher proportion of calls than previously possible. Most programs from a representative set of Go programs now see between 2 and 14% improvement from enabling PGO.
TODO: https://go.dev/issue/62577: cmd/link, cmd/go: emit split DWARF on darwin
TODO: complete this section, or delete if not needed
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.
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
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
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
TODO: https://go.dev/issue/56381: allow terminating Scanner early cleanly without a final token or an error
TODO: https://go.dev/cl/498416: cmd: add a new analyzer for check missing values after append
TODO: https://go.dev/issue/60204: add Or
TODO: https://go.dev/cl/504883: cmp: add Or; modified api/next/60204.txt
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
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
The new Null[T] type
provide a way to scan nullable columns for any column types.
The new methods AppendEncode and AppendDecode added to
each of the Encoding types in the packages
encoding/base32,
encoding/base64, and
encoding/hex
simplify encoding and decoding from and to byte slices by taking care of byte slice buffer management.
The methods
base32.Encoding.WithPadding and
base64.Encoding.WithPadding
now panic if the padding argument is a negative value other than
NoPadding.
The following declarations related to
syntactic identifier resolution
are now deprecated:
Ident.Obj,
Object,
Scope,
File.Scope,
File.Unresolved,
Importer,
Package,
NewPackage.
Identifiers cannot be accurately resolved without type information.
Consider, for example, the identifier K
in T{K: ""}: it could be the name of a local variable
if T is a map type, or the name of a field if T is a struct type.
New programs should use the go/types
package to resolve identifiers;
see Object, Info.Uses,
and Info.Defs for details.
The new Alias type represents type aliases.
Previously, type aliases were not represented explicitly, so a reference to a type alias was equivalent
to spelling out the aliased type, and the name of the alias was lost.
The new representation retains the intermediate Alias.
This enables improved error reporting (the name of an alias can be reported), and allows for better handling
of cyclic type declarations involving type aliases.
In a future release, Alias types will also carry type parameter information.
The new function Unalias returns the actual type denoted by an
Alias type (or any other Type for that matter).
Because Alias types may break existing type switches that do not know to check for them,
this functionality is controlled by a GODEBUG field named gotypesalias.
With gotypesalias=0, everything behaves as before, and Alias types are never created.
With gotypesalias=1, Alias types are created and clients must expect them.
The default is gotypesalias=0.
In a future release, the default will be changed to gotypesalias=1.
The Info struct now exports the
FileVersions map
which provides per-file Go version information.
The new helper method PkgNameOf returns the local package name
for the given import declaration.
The implementation of SizesFor has been adjusted to compute
the same type sizes as the compiler when the compiler argument for SizesFor is "gc".
The default Sizes implementation used by the type checker is now
types.SizesFor("gc", "amd64").
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.
The new go/version package implements functions
for validating and comparing Go version strings.
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
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
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
The new method Rat.FloatPrec computes the number of fractional decimal digits required to represent a rational number accurately as a floating-point number, and whether accurate decimal representation is possible in the first place.
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
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
TODO: https://go.dev/cl/539615: net/http/cgi: the PATH_INFO should be empty or start with a slash
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
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
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
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.
TODO: https://go.dev/issue/63340: provide histogram of all STW events
Mutex profiles now scale contention by the number of goroutines blocked on the mutex. This provides a more accurate representation of the degree to which a mutex is a bottleneck in a Go program. For instance, if 100 goroutines are blocked on a mutex for 10 milliseconds, a mutex profile will now record 1 second of delay instead of 10 milliseconds of delay.
CPU profiles on Darwin platforms now contain the process's memory map, enabling the disassembly view in the pprof tool.
The execution tracer has been completely overhauled in this release, resolving several long-standing
issues and paving the way for new use-cases for execution traces.
Execution traces now use the operating system's clock on most platforms (Windows excluded) so
it is possible to correlate them with traces produced by lower-level components.
Execution traces no longer depend on the reliability of the platform's clock to produce a correct trace.
Execution traces are now partitioned regularly on-the-fly and as a result may be processed in a
streamable way.
Execution traces now contain complete durations for all system calls.
Execution traces now contain information about the operating system threads that goroutines executed on.
The latency impact of starting and stopping execution traces has been dramatically reduced.
Execution traces may now begin or end during the garbage collection mark phase.
To allow Go developers to take advantage of these improvements, an experimental
trace reading package is available at golang.org/x/exp/trace.
Note that this package only works on traces produced by programs built with Go 1.22 at the moment.
Please try out the package and provide feedback on
the corresponding proposal issue.
If you experience any issues with the new execution tracer implementation, you may switch back to the
old implementation by building your Go program with GOEXPERIMENT=noexectracer2.
If you do, please file an issue, otherwise this option will be removed in a future release.
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.
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
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
On macOS on 64-bit x86 architecture (the darwin/amd64 port),
the Go toolchain now generates position-independent executables (PIE) by default.
Non-PIE binaries can be generated by specifying the -buildmode=exe
build flag.
On 64-bit ARM-based macOS (the darwin/arm64 port),
the Go toolchain already generates PIE by default.
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