What's coming in Go 1.24
London Gophers, 2024 - Daniel Martí
@mvdan.cc
Caveat: my personal picks.
We are two months away.
master frozen for features tomorrow
Go 1.24rc1 - 2nd week December
Go 1.24.0 - 2nd week February
Most of these are merged.
Will share the slides with links.
Here we will only skim the surface!
Section 1: Language
type set[P comparable] = map[P]bool
That's it this time.
Section 2: Toolchain
$ go run golang.org/x/tools/cmd/stringer@latest
$ go run golang.org/x/tools/cmd/stringer@v0.27.0
$ go get golang.org/x/tools/cmd/stringer@v0.27.0
$ go run golang.org/x/tools/cmd/stringer
$ go mod tidy # removed from go.mod!
$ go get -tool golang.org/x/tools/cmd/stringer@v0.27.0
$ go tool stringer
$ go install mvdan.cc/sh/v3/cmd/shfmt@v3.9.0
$ shfmt -version
v3.9.0
$ go install mvdan.cc/sh/v3/cmd/shfmt@v3.9.0
$ shfmt -version
v3.9.0
$ git switch -d v3.9.0
HEAD is now at 7bd422f9 CHANGELOG: prepare for v3.9.0
$ go install ./cmd/shfmt
$ shfmt -version
(devel)
go test -json
now prints build failures as JSON
Section 3: Standard Library
x := NewTimeBasedCache(...)
x.Put(key, value)
assert(t, x.Has(key))
time.Sleep(2 * time.Minute)
assert(t, !x.Has(key))
clock := NewMockClock()
x := NewTimeBasedCache(clock, …)
x.Put(key, value)
assert(t, x.Has(key))
clock.Advance(2 * time.Minute)
assert(t, !x.Has(key))
synctest.Run(func() {
x := NewTimeBasedCache(...)
x.Put(key, value)
assert(t, x.Has(key))
time.Sleep(2 * time.Minute)
synctest.Wait()
assert(t, !x.Has(key))
})
Parting thought:
Skimming over master is very useful.
go install golang.org/dl/gotip@latest