Blog
Tech4 min read

Go 1.26 Recap: Green Tea GC Is On

A new garbage collector by default, new(expr), errors.AsType, and go fix that modernizes your code. Go 1.26 in five minutes.

#golang #go-recap #performance

Go recap series — one short post per release. Released February 2026.

TL;DR

  • Green Tea GC is the default: 10–40% less GC overhead.
  • new(expr) — make a pointer from a value in one step.
  • errors.AsType[T](err) — errors.As without the extra variable.
  • go fix ./... upgrades old code to modern Go.
  • cgo calls ~30% cheaper, io.ReadAll ~2× faster.

1. Green Tea GC

What changed: the garbage collector now scans small objects one memory page (span) at a time, instead of jumping from object to object across the heap.

The Go team expects 10–40% less GC overhead in real programs, and about 10% more on newer CPUs (Intel Ice Lake, AMD Zen 4 and later).

Why it matters: less CPU spent on GC, by just upgrading.

2. new(expr)

go
type User struct {
    Age *int `json:"age,omitzero"`
}

// before: age := yearsSince(born); u := User{Age: &age}
u := User{Age: new(yearsSince(born))}

Why it matters: optional pointer fields without a temporary variable.

3. errors.AsType

go
if pathErr, ok := errors.AsType[*fs.PathError](err); ok {
    log.Println("failed path:", pathErr.Path)
}

Why it matters: shorter, type-safe, and faster than errors.As.

4. go fix modernizes your code

text
$ go fix ./...

What it does: rewrites old patterns to modern Go features and APIs.

Why it matters: run it after every upgrade — free cleanup.

5. Worth knowing

  • Generic types can reference themselves in constraints: type Adder[A Adder[A]] interface { Add(A) A }.
  • log/slog.NewMultiHandler sends logs to several handlers.
  • crypto/hpke (new) and post-quantum TLS key exchanges enabled by default.
  • Experimental: goroutine leak profile and simd/archsimd.

Previous: ← Go 1.25 Recap · Next: Go 1.27 Recap →

Source: Go 1.26 release notes

Share To Friends