Blog
Tech5 min read

Go 1.27 Recap: Generic Methods, JSON v2, and uuid

Methods can finally have their own type parameters, encoding/json runs on v2, UUIDs are in the standard library, and goroutine leak detection is ready.

#golang #go-recap #generics

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

TL;DR

  • Generic methods: a method can declare its own type parameters.
  • encoding/json now runs on the v2 engine — faster decoding.
  • New uuid package in the standard library.
  • Goroutine leak profile is ready for production.
  • Small allocations up to 30% cheaper.

1. Generic methods

What changed: methods can now have their own type parameters.

go
type List[T any] struct {
    items []T
}

func (l *List[T]) Map[U any](f func(T) U) *List[U] {
    out := &List[U]{}
    for _, v := range l.items {
        out.items = append(out.items, f(v))
    }
    return out
}

names := users.Map(func(u User) string { return u.Name })

Two rules: interface methods still can't have type parameters, and a generic method can't satisfy an interface.

Why it matters: list.Map(f) instead of a package-level Map(list, f).

2. encoding/json runs on v2

What changed: encoding/json/v2 is now a regular package, and the old encoding/json uses the v2 engine under the hood.

Why it matters: faster decoding with no code changes.

Watch out:

  • The v2 API rejects invalid UTF-8 and duplicate keys by default.
  • Error messages may differ — don't compare error strings in tests.
  • Escape hatch: GOEXPERIMENT=nojsonv2 (temporary).

3. uuid in the standard library

go
import "uuid"

id := uuid.NewV7() // time-ordered, good for database keys
fmt.Println(id)

parsed, err := uuid.Parse(input)

Also: uuid.New() (version 4 today), NewV4, MustParse, Nil, Max.

Why it matters: one less third-party dependency.

4. Goroutine leak detection

What changed: the goroutineleak profile is generally available — in runtime/pprof and at /debug/pprof/goroutineleak.

Why it matters: finds goroutines stuck forever — the classic "forgot to close the channel" bug.

Limit: if the channel is still reachable from a global, it won't be reported.

5. Worth knowing

  • Faster small allocations: up to 30% cheaper under 80 bytes (~1% overall).
  • strings.CutLast and bytes.CutLast.
  • crypto/mldsa: post-quantum signatures, usable in X.509 and TLS 1.3.
  • go doc pkg@v1.2.3 reads docs for a specific version.
  • go tool trace -http=:6060 now listens on localhost only.

Upgrading from an old version?


Previous: ← Go 1.26 Recap · Start of series: Go 1.22 Recap

Source: Go 1.27 release notes

Share To Friends