Shattered Mirror: An Introduction to Reflect and Unsafe
summary
A custom state machine executor is built that wires step functions together with runtime dependency injection using reflect.MakeFunc and inspection of function signatures; it works but produces opaque stack traces and a brittle “mess in the middle.” The talk shows how reflect inspects and constructs types and values at runtime (including marshaling), and how unsafe.Pointer and uintptr let syscall bindings and pointer casts bypass Go’s type system; conclusion: reflect is fine for reading or marshaling, avoid reflection for runtime DI and avoid unsafe unless necessary.
AI-written summary · about
chapters (9)
- 0:00Reflect and Unsafe intro
- 1:46Why reflect and unsafe matter
- 3:30Go’s type system
- 6:49Exploring reflect package
- 10:29Reflect in dependency injection
- 11:35Unsafe in Go
- 13:51How unsafe powers reflect
- 14:58Reflect pitfalls
- 16:44Best practices for reflect








