Writing a code generator to make your code more secure
summary
A small CLI generator called beef escape is built to auto-create Go methods that hide credentials by implementing the stringer and go string printing interfaces, so sensitive values print as stars. It uses packages.Load to inspect the package, selects templates based on whether the underlying type is string, writes a _generated.go file and runs go generate and go import on it. The demo runs and prints masked values as expected.
AI-written summary · about
chapters (21)
- 0:00Intro
- 1:09About Blacklane
- 1:45Motivation
- 2:05Agenda
- 2:28Whats a code generator
- 3:18Examples
- 4:00Why are they useful
- 4:28How to use them
- 6:13Ingo
- 8:25Code Generation
- 10:01Load more than one package
- 10:32Inspecting the package
- 11:25Text template package
- 11:59Two types of types
- 12:35Inspecting the type
- 13:15Generating the code
- 13:55Saving the code
- 14:26Importing the code
- 15:51Code generator
- 16:01Go Generate
- 17:29Demo Type
