Redowan's Reflections
Recent writing
How Go 1.20's WithCancelCause and Go 1.21's WithTimeoutCause let you attach a reason to context cancellation, plus a gotcha with manual cancel and the stdlib pattern that covers every path.
How Python and Kotlin provide structured concurrency out of the box while Go achieves the same patterns explicitly using errgroup, WaitGroup, and context.
Practical patterns for mocking in Go without external libraries. Learn to mock functions, methods, interfaces, HTTP calls, and time using only the standard library
Master shadow testing for large-scale system migrations. Learn to safely rewrite services by comparing outputs between old and new implementations.
Simplify Go error handling by consolidating validation and system errors. Learn when to return boolean vs error for clearer failure modes.
Test Go subprocesses with the re-exec pattern: spawn your test binary as a subprocess to emulate real command behavior reliably.
Apply SOLID's Interface Segregation Principle in Go with consumer-defined contracts. Learn why small interfaces and implicit implementation matter.
Master Go context keys with custom types, avoid collisions using empty structs, and learn accessor patterns for safe request-scoped values.
Organize Go tests with in-package, external _test packages, and integration tests. Learn white-box vs black-box testing conventions.
Organize Go subtests with t.Run nesting and parallel execution. Learn patterns for setup, teardown, and readable test hierarchies.
Organize Go apps by domain, not technology. Learn why models/controllers structure hurts and how bounded contexts create better separation.
Avoid brittle AI-generated tests that check implementation details. Write maintainable tests that verify behavior, not method calls.
Prevent goroutine leaks caused by early returns with unbuffered channels. Learn buffering, draining, errgroup patterns, and goleak testing.
Master Go test lifecycle with t.Cleanup(), subtests, and TestMain. Learn per-test, grouped, and package-wide setup patterns effectively.
Separate business logic from external service calls using the Gateway pattern. Apply dependency inversion and interface segregation in Go.