1 of 52

What's coming in Go 1.24

London Gophers, 2024 - Daniel Martí

@mvdan.cc

2 of 52

Caveat: my personal picks.

3 of 52

We are two months away.

master frozen for features tomorrow

Go 1.24rc1 - 2nd week December

Go 1.24.0 - 2nd week February

4 of 52

5 of 52

6 of 52

Most of these are merged.

7 of 52

Will share the slides with links.

Here we will only skim the surface!

8 of 52

Section 1: Language

9 of 52

Generic type aliases

https://go.dev/issue/46477

10 of 52

type set[P comparable] = map[P]bool

11 of 52

That's it this time.

12 of 52

Section 2: Toolchain

13 of 52

track tool deps in go.mod

https://go.dev/issue/48429

14 of 52

$ 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

15 of 52

stamp versions in binaries in

"go build"

https://go.dev/issue/50603

16 of 52

$ go install mvdan.cc/sh/v3/cmd/shfmt@v3.9.0

$ shfmt -version

v3.9.0

17 of 52

$ 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)

18 of 52

cmd/go http auth via GOAUTH

https://go.dev/issue/26232

19 of 52

20 of 52

go test -json

now prints build failures as JSON

21 of 52

adopt Go 1.22 as bootstrap toolchain

https://go.dev/issue/64751

22 of 52

23 of 52

improve scaling of mutexes

https://go.dev/issue/68578

24 of 52

//go:wasmexport

https://go.dev/issue/65199

25 of 52

serve module under VCS subdirectory

https://go.dev/issue/34055

26 of 52

Linux 3.2 now required

https://go.dev/issue/67001

27 of 52

Section 3: Standard Library

28 of 52

crypto: FIPS certification

https://go.dev/issue/69536

29 of 52

30 of 52

runtime.AddCleanup

https://go.dev/issue/67535

31 of 52

hash/maphash.Comparable

https://go.dev/issue/54670

32 of 52

os: safer file open funcs

https://go.dev/issue/67002

33 of 52

testing/synctest: experimental package to test concurrent code

https://go.dev/issue/69687

34 of 52

x := NewTimeBasedCache(...)

x.Put(key, value)

assert(t, x.Has(key))

time.Sleep(2 * time.Minute)

assert(t, !x.Has(key))

35 of 52

clock := NewMockClock()

x := NewTimeBasedCache(clock, …)

x.Put(key, value)

assert(t, x.Has(key))

clock.Advance(2 * time.Minute)

assert(t, !x.Has(key))

36 of 52

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))

})

37 of 52

bytes, strings: more iter funcs

(Lines, SplitSeq, FieldsSeq, …)

https://go.dev/issue/61901

38 of 52

go/types also gains

iter methods!

https://go.dev/issue/66626

39 of 52

GOEXPERIMENT=synchashtriemap

for a faster sync.Map

https://go.dev/cl/608335

40 of 52

testing.TB.Context

https://go.dev/issue/36532

41 of 52

testing.TB.Chdir

https://go.dev/issue/62516

42 of 52

crypto/rand: crash on read errors

https://go.dev/issue/66821

43 of 52

crypto/rand: use new Linux vDSO

https://go.dev/issue/69577

44 of 52

x/crypto: migrate packages to std

(sha3, pbkdf2, hkdf, argon2, …)

https://go.dev/issue/65269

45 of 52

deprecate runtime.GOROOT

https://go.dev/issue/51473

46 of 52

encoding/json omitzero option

https://go.dev/issue/45669

47 of 52

48 of 52

log/slog.DiscardHandler

https://go.dev/issue/62005

49 of 52

encoding: TextAppender and BinaryAppender

https://go.dev/issue/62384

50 of 52

Parting thought:

Skimming over master is very useful.

51 of 52

go install golang.org/dl/gotip@latest

52 of 52