Write Less (Code), Generate More
summary
Argues that Go code generation reduces repeated boilerplate by example: builds a simple generator that uses go/packages and AST/type info to find all constants of a named integer type and emits a formatted String() method into a gen_ file via a text template and gofmt. Integrates generation into workflow with go generate and a go-generate wrapper that adds an artifact cache and dependency-aware ordering. The generator works but omits edge cases and optimizations.
AI-written summary · about
chapters (5)
- 0:00Start
- 7:50automate the process of running code generators
- 12:38the abstract syntax tree
- 17:37create an output file
- 20:17integrate cogeneration
related talks
36mGenerating code in Go
27mInception: Go programs that generate Go code
22mGenerating Generators
51mGenerate You Some Code for Great Good
51mCode generation tips you didn't ask for
36mCode Generation to Survive
42mBecoming the Metaprogrammer Real World Code Generation
37mThings I learned after a decade of writing code generators
