Refactor Cloud applications in Go 1.18 with generics
summary
Go 1.18 adds generics, type sets and constraints so code can be parameterized for functions, structs and methods; the demo refactors genny-generated functions into a single generic Max and a generic HTTP middleware, removes a dependency on genny and reduces codebase by over 40%. It uses golang/x/exp constraints (and the experimental constraints package) to bound numeric types, compiles with type inference, and Cloud Run deploys successfully after refactor.
AI-written summary · about
chapters (7)
- 0:00Introduction to Go generics
- 2:39Understanding type sets
- 6:32Generics vs. other languages
- 7:55When to use generics
- 9:19When to avoid generics
- 10:57Refactoring a web app
- 22:53Conclusion and recap








