Go 1.24 Recap: Faster Maps, Honest Benchmarks
Maps become Swiss Tables, b.Loop() fixes benchmarks, tools move into go.mod, and os.Root blocks path traversal. Go 1.24 in five minutes.
#golang #go-recap #performance
Go recap series — one short post per release. Released February 2025.
TL;DR
- Built-in
mapis now a Swiss Table — about 2–3% less CPU on average. for b.Loop()replacesfor range b.Nin benchmarks.- Dev tools are tracked in
go.modwithgo get -tool. os.Rootkeeps file access inside one directory.- Generic type aliases,
omitzero, weak pointers, post-quantum crypto.
1. Maps are Swiss Tables
What changed: the built-in map was rewritten. Together with runtime tweaks, the Go team measured 2–3% less CPU overhead on average.
How it works: slots are grouped by 8. Each group has a small control word with a short fingerprint of each key. A lookup checks all 8 fingerprints at once and only compares the keys that match.
Why it matters: free speed. Just upgrade.
2. b.Loop() for benchmarks
func BenchmarkParse(b *testing.B) {
input := loadFixture() // runs once
for b.Loop() {
Parse(input)
}
}
Why it matters: setup runs once, and the compiler can't optimize away the code you are measuring. Your numbers are more honest.
3. Tools live in go.mod
$ go get -tool golang.org/x/tools/cmd/stringer
$ go tool stringer -type=Color
Why it matters: no more tools.go with blank imports. go install tool installs them all.
4. os.Root stops path traversal
root, err := os.OpenRoot("/srv/uploads")
if err != nil {
return err
}
f, err := root.Open(name) // cannot escape /srv/uploads
Why it matters: if users send you file names, this is the easiest security fix you'll ship.
5. Small but useful
- Generic type aliases:
type Set[T comparable] = map[T]struct{}. omitzeroJSON tag: skips zero values — including a zerotime.Time, whichomitemptycan't.runtime.AddCleanupreplacesSetFinalizer, and theweakpackage adds weak pointers for caches.- Post-quantum crypto:
crypto/mlkem, and TLS usesX25519MLKEM768by default.
Previous: ← Go 1.23 Recap · Next: Go 1.25 Recap →
Source: Go 1.24 release notes
