Go
Notes on the Go programming language — interfaces, concurrency, testing, and patterns that have held up in production.
Prevent dangerous struct copies with noCopy sentinel and go vet's copylock checker. Protect mutexes and sync primitives from value copies.
Pin tool versions in Go 1.24 with the new 'tool' directive. Replace tools.go pattern with native go.mod support for project tooling.
Test functions that write to stdout/stderr in Go by capturing output with os.Pipe. Learn patterns to avoid deadlocks in concurrent tests.
Return teardown closures from test helpers to manage cleanup elegantly. Learn patterns for temp files, mock servers, and t.Cleanup() usage.
Compare three Go slice sorting methods: sort.Interface, sort.Slice with closures, and modern generic slices.Sort with type safety.
Debug tricky nil comparisons in Go interfaces. Understand dynamic types, type assertions, and use reflect for generic nil checking.
Compare middleware stacking with embedded delegation in Go HTTP servers. Learn when to override ServeHTTP for simpler request handling.
Understand why io.Reader takes a byte slice parameter instead of returning one. Learn about heap allocations and buffer reuse in Go streams.
Avoid common Go slice mistakes: shared backing arrays, nil vs empty slices, append behavior, and slice copying pitfalls explained.
Implement single-method interfaces with function types instead of structs. Master http.HandlerFunc patterns for middlewares, mocks, and adapters.
Implement topological sorting in Go to order tasks by dependencies. Process directed acyclic graphs for build systems and scheduling.
Build a production-ready circuit breaker in Go from scratch with closed, open, and half-open states to prevent cascading failures.
Discover a simpler alternative to functional options: method chaining with builder-style configuration that's 76x faster and easier to understand.
Replace inheritance with the Strategy pattern in Go using interfaces. Achieve composable, testable code without class hierarchies.
Learn how to build custom error types in Go to create stack traces without runtime overhead, inspired by Rob Pike's Upspin error handling.