Go📜History & Evolutionbeginner
Generics — Go 1.18 (2022)
Go · History & Evolution · Run with go run
Explanation
Go 1.18, released March 2022, added generics (officially called "type parameters") — the most significant language change since Go 1.0. After a decade of community debate (Rob Pike himself was initially skeptical), the team landed on a design using type parameter lists and interface constraints.
Real-World Scenario
Before generics, writing a `Min(a, b int) int` that also worked for `float64` required either code duplication or `interface{}` with reflection and type assertions. With generics: `func Min[T constraints.Ordered](a, b T) T { if a < b { return a }; return b }`.