Redowan's Reflections https://rednafi.com/ Recent content on Redowan's Reflections Redowan's Reflections https://blob.rednafi.com/static/images/home/cover.png https://rednafi.com/ Hugo -- 0.160.1 en Sun, 26 Apr 2026 23:06:42 +0200 Go quirks: function closures capturing mutable references https://rednafi.com/go/closure-mutable-refs/ Sat, 25 Apr 2026 00:00:00 +0000 https://rednafi.com/go/closure-mutable-refs/ A Go closure holds a live reference to whatever it captures, not a snapshot. Real examples of where this trips people up, and how to keep it boring. Go Concurrency Accepted proposal: UUID in the Go standard library https://rednafi.com/shards/2026/04/go-uuid/ Sun, 19 Apr 2026 00:00:00 +0000 https://rednafi.com/shards/2026/04/go-uuid/ Notes on Go's newly accepted uuid proposal and the tradeoffs behind the API. Go API Peeking into Go struct tags https://rednafi.com/go/struct-tags/ Sat, 18 Apr 2026 00:00:00 +0000 https://rednafi.com/go/struct-tags/ A quick tour of Go struct tags: how different libraries use them, how you read them at runtime with reflection, and how other tools read them at build time instead. Go Reflection Codegen Error translation in Go services https://rednafi.com/go/error-translation/ Sun, 12 Apr 2026 00:00:00 +0000 https://rednafi.com/go/error-translation/ Translating errors at layer boundaries so storage details don't leak into the handler or, worse, into client responses. Go Error Handling Dynamo: Amazon's highly available key-value store https://rednafi.com/shards/2026/04/dynamo/ Sat, 11 Apr 2026 00:00:00 +0000 https://rednafi.com/shards/2026/04/dynamo/ Key takeaways from Amazon's 2007 Dynamo paper. Distributed Systems Databases Stacked log lines considered harmful https://rednafi.com/shards/2026/04/no-stacked-loglines/ Tue, 07 Apr 2026 00:00:00 +0000 https://rednafi.com/shards/2026/04/no-stacked-loglines/ Why logging at every layer of a service produces noise, and how to log only at the handler level while propagating context from below. Go Distributed Systems Observability What's the ideal dispatch mechanism? https://rednafi.com/shards/2026/03/ideal-dispatch-mechanism/ Tue, 31 Mar 2026 00:00:00 +0000 https://rednafi.com/shards/2026/03/ideal-dispatch-mechanism/ Switch, map of functions, and interface registry for dispatching in Go. Go API Background jobs and inherited file descriptors https://rednafi.com/shards/2026/03/background-jobs-inherited-fd/ Sat, 28 Mar 2026 00:00:00 +0000 https://rednafi.com/shards/2026/03/background-jobs-inherited-fd/ Why & backgrounds execution but doesn't stop output from flooding your terminal. Shell Unix Testing unary gRPC services in Go https://rednafi.com/go/testing-unary-grpc-services/ Mon, 23 Mar 2026 00:00:00 +0000 https://rednafi.com/go/testing-unary-grpc-services/ How to test unary gRPC services in Go - handler logic, interceptors, deadlines, metadata propagation, and rich error details - all in-memory with bufconn. Go gRPC Testing Distributed Systems Repositories, transactions, and unit of work in Go https://rednafi.com/go/repo-txn-uow/ Sat, 21 Mar 2026 00:00:00 +0000 https://rednafi.com/go/repo-txn-uow/ Decoupling business logic from storage in Go, adding transaction support without leaking SQL details, and coordinating atomic writes across multiple repositories using a unit of work. Go Database Design Patterns How do you handle transactions with the repository pattern? https://rednafi.com/shards/2026/03/transactions-with-repository-pattern/ Fri, 20 Mar 2026 00:00:00 +0000 https://rednafi.com/shards/2026/03/transactions-with-repository-pattern/ Adding transaction support to a repository interface without leaking storage details. Go Database Is passing user ID through context an antipattern? https://rednafi.com/shards/2026/03/user-id-through-context/ Wed, 18 Mar 2026 00:00:00 +0000 https://rednafi.com/shards/2026/03/user-id-through-context/ Why the middleware-to-handler boundary is a special case for context values. Go API Distributed Systems What belongs in Go's context values? https://rednafi.com/shards/2026/03/what-belongs-in-go-context-values/ Tue, 17 Mar 2026 00:00:00 +0000 https://rednafi.com/shards/2026/03/what-belongs-in-go-context-values/ A simple litmus test for when to use context values in Go. Go API Distributed Systems Do you need a repository layer on top of sqlc? https://rednafi.com/shards/2026/03/repository-layer-over-sqlc/ Mon, 16 Mar 2026 00:00:00 +0000 https://rednafi.com/shards/2026/03/repository-layer-over-sqlc/ Decoupling business logic from storage with a small interface in Go. Go Database Wrapping a gRPC client in Go https://rednafi.com/go/wrap-grpc-client/ Sun, 15 Mar 2026 00:00:00 +0000 https://rednafi.com/go/wrap-grpc-client/ How to wrap a generated gRPC client behind a clean Go API so users never have to touch protobuf types or connection management directly. Go gRPC API Distributed Systems In praise of the etcd codebase https://rednafi.com/shards/2026/03/etcd-codebase/ Sat, 14 Mar 2026 00:00:00 +0000 https://rednafi.com/shards/2026/03/etcd-codebase/ Why the etcd codebase is my go-to reference for building gRPC services in Go. Go gRPC Distributed Systems Go errors: to wrap or not to wrap? https://rednafi.com/go/to-wrap-or-not-to-wrap/ Sat, 07 Mar 2026 00:00:00 +0000 https://rednafi.com/go/to-wrap-or-not-to-wrap/ Exploring the tradeoffs between wrapping errors at every return site versus wrapping only at boundaries, with no definitive answer - just honest tradeoffs for the kind of software I write. Go Error Handling Mutate your locked state inside a closure https://rednafi.com/go/mutex-closure/ Thu, 05 Mar 2026 00:00:00 +0000 https://rednafi.com/go/mutex-closure/ Why your mutex wrapper should accept a closure for mutation instead of a plain value, with examples from the standard library and Tailscale. Go Concurrency API What canceled my Go context? https://rednafi.com/go/context-cancellation-cause/ Tue, 24 Feb 2026 00:00:00 +0000 https://rednafi.com/go/context-cancellation-cause/ 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. Go Error Handling Concurrency Structured concurrency & Go https://rednafi.com/go/structured-concurrency/ Sat, 21 Feb 2026 00:00:00 +0000 https://rednafi.com/go/structured-concurrency/ How Python and Kotlin provide structured concurrency out of the box while Go achieves the same patterns explicitly using errgroup, WaitGroup, and context. Go Python Kotlin Concurrency Your Go tests probably don't need a mocking library https://rednafi.com/go/mocking-libraries-bleh/ Fri, 23 Jan 2026 00:00:00 +0000 https://rednafi.com/go/mocking-libraries-bleh/ Practical patterns for mocking in Go without external libraries. Learn to mock functions, methods, interfaces, HTTP calls, and time using only the standard library Go Testing API Tap compare testing for service migration https://rednafi.com/system/tap-compare-testing/ Sat, 13 Dec 2025 00:00:00 +0000 https://rednafi.com/system/tap-compare-testing/ Master shadow testing for large-scale system migrations. Learn to safely rewrite services by comparing outputs between old and new implementations. Distributed Systems Go Testing Splintered failure modes in Go https://rednafi.com/go/splintered-failure-modes/ Sun, 30 Nov 2025 00:00:00 +0000 https://rednafi.com/go/splintered-failure-modes/ Simplify Go error handling by consolidating validation and system errors. Learn when to return boolean vs error for clearer failure modes. Go Error Handling Re-exec testing Go subprocesses https://rednafi.com/go/test-subprocesses/ Sun, 16 Nov 2025 00:00:00 +0000 https://rednafi.com/go/test-subprocesses/ Test Go subprocesses with the re-exec pattern: spawn your test binary as a subprocess to emulate real command behavior reliably. Go Testing Revisiting interface segregation in Go https://rednafi.com/go/interface-segregation/ Sat, 01 Nov 2025 00:00:00 +0000 https://rednafi.com/go/interface-segregation/ Apply SOLID's Interface Segregation Principle in Go with consumer-defined contracts. Learn why small interfaces and implicit implementation matter. Go API Testing Avoiding collisions in Go context keys https://rednafi.com/go/avoid-context-key-collisions/ Wed, 22 Oct 2025 00:00:00 +0000 https://rednafi.com/go/avoid-context-key-collisions/ Master Go context keys with custom types, avoid collisions using empty structs, and learn accessor patterns for safe request-scoped values. Go API Performance Organizing Go tests https://rednafi.com/go/organizing-tests/ Wed, 08 Oct 2025 00:00:00 +0000 https://rednafi.com/go/organizing-tests/ Organize Go tests with in-package, external _test packages, and integration tests. Learn white-box vs black-box testing conventions. Go Testing Subtest grouping in Go https://rednafi.com/go/subtest-grouping/ Wed, 01 Oct 2025 00:00:00 +0000 https://rednafi.com/go/subtest-grouping/ Organize Go subtests with t.Run nesting and parallel execution. Learn patterns for setup, teardown, and readable test hierarchies. Go Testing Let the domain guide your application structure https://rednafi.com/go/app-structure/ Sat, 20 Sep 2025 00:00:00 +0000 https://rednafi.com/go/app-structure/ Organize Go apps by domain, not technology. Learn why models/controllers structure hurts and how bounded contexts create better separation. Go Test state, not interactions https://rednafi.com/go/test-state-not-interactions/ Sun, 14 Sep 2025 00:00:00 +0000 https://rednafi.com/go/test-state-not-interactions/ Avoid brittle AI-generated tests that check implementation details. Write maintainable tests that verify behavior, not method calls. Go Testing