What’s New in Go 1.23? Key Features and Improvements Explained
Go 1.23 introduces a range‑over‑func iterator, generic type alias preview, optional telemetry, several go command enhancements, numerous standard library updates, and compiler and linker optimizations, providing developers with a more powerful and flexible programming environment.
Go 1.23 has been released, bringing several new language features and tool improvements.
1. New iterator syntax
range‑over‑func : In a for‑range loop you can now use an iterator function as the range expression, e.g. func (func (K) bool) . This enables custom iterators for arbitrary sequences and the standard slices and maps packages gain iterator support.
2. Generic type alias preview
Go 1.23 previews generic type alias support. Enable it with GOEXPERIMENT=aliastypeparams . The alias can be used within a package (cross‑package not yet supported), reducing code duplication.
3. Telemetry system
An optional telemetry system can collect usage and error statistics from the Go toolchain. Enable it with go telemetry on ; it is off by default.
4. Go command improvements
go env -changed : Shows environment variables that differ from defaults.
go mod tidy -diff : Shows a preview of changes to go.mod and go.sum without modifying files.
go vet enhancements : Reports symbols that are new in the target Go version, helping migration.
5. Standard library and tool updates
iter package: Adds iterator‑related functionality.
structs package: Introduces marker types for modifying struct fields.
unique package: Provides interning utilities for value deduplication.
time.Timer and time.Ticker implementations have been optimized for better performance and accuracy.
slices package adds a Repeat method that returns a new slice repeating the original a given number of times.
os.DirFS returns a file system rooted at a directory; combined with os.CopyFS it enables one‑shot recursive copy of files and directories.
panic function now indents the second and subsequent lines of the error message with a tab, distinguishing them from the first goroutine’s stack trace.
net/http adds ParseCookie and ParseSetCookie for extracting cookie structs from header strings.
6. Other improvements
Compiler optimizations : Overlaps stack slots for local variables and uses profile‑guided optimization to reduce compile time.
Linker restrictions : Disallows //go:linkname references to unmarked standard‑library symbols unless they are widely used.
OS requirements : Go 1.23 requires macOS 11+ and is the last version supporting Linux 2.6.32; Go 1.24 will need Linux 3.17+.
ARM64 and RISC‑V : New environment variables GOARM64 and GORISCV64 let you specify target architecture versions.
Go 1.23’s release marks continued progress in the language’s standard library and toolchain, offering developers a more efficient and flexible programming environment.
21CTO
21CTO (21CTO.com) offers developers community, training, and services, making it your go‑to learning and service platform.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
