10. Generics

Generics1 were first introduced to Go with the release of Go 1.182 in March 2022, as we were writing this book. We, like the Go team, have tried our best to present the current idioms and thoughts on the how, what, when, where, and why questions about generics in Go.

1. https://en.wikipedia.org/wiki/Generic_programming

2. https://go.dev/blog/intro-generics

What Are Generics?

Generic programming is a programming paradigm that allows you to stub out the implementation of a function with a type that will be provided later. This has benefits for both writing and using generic functions. With generics, you can write functions that can work with multiple types directly without having to write the same function multiple times, once for ...

Get Go Fundamentals: Gopher Guides now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.