Generics in Go have come a long way since 1.18. Type inference got smarter, the standard library absorbed slices, maps, and cmp, and call-site noise mostly disappeared. Now, with Go 1.27, the final major piece lands, and it's the headline language change of the release: generic methods, methods that can declare their own standalone type parameters, even when the receiver type is not generic.

This cheat sheet covers all three levels of Go generics — functions, types, and generic methods — with practical examples, real-world stdlib patterns, and key gotchas to keep in mind.

Quick Reference Card

These three patterns form the backbone of Go’s new expressive power — without sacrificing simplicity.

// 1. Generic Function