Generating code in Go
summary
Argues that generating Go code gives compile‑time safety and fewer runtime surprises, with concrete tools and results: using gqlgen moves GraphQL errors into the compiler and “squashes many bugs,” using sqlboiler turns DB schema into a generated ORM where a plain ten‑line Find exposes the SQL, and using decorators generated via go:generate ensures traces/logs/metrics are added automatically so telemetry stops being missed. Offers CI and Makefile rules to keep generated code reproducible.
AI-written summary · about
chapters (11)
- 0:00Introduction to code generation
- 1:36Goals of the presentation
- 2:29Why use code generation
- 5:00Basics of Go code generation
- 7:08Generating API code
- 10:13Generating ORM code
- 14:17Generating decorators
- 18:10Best practices and challenges
- 20:48Live coding demonstration
- 28:00Summary and conclusions
- 30:03Q&A session
related talks
42mBecoming the Metaprogrammer Real World Code Generation
36mCode Generation to Survive
30mWrite Less (Code), Generate More
09mThe new GraphQL Codegen
51mGenerate You Some Code for Great Good
16mTools for working with Go Code
27mInception: Go programs that generate Go code
51mCode generation tips you didn't ask for
