eb9171368b2567474a670a0413bc6a8e4bb507c9
Added 'When to Use' subsections with concrete decision triggers and before/after Go code examples to patterns across all directories: - patterns/error-handling.md (3 patterns: sentinels, wrapping, Join) - patterns/concurrency.md (4 patterns: Mutex, Once, done channels, pipelines) - patterns/interfaces.md (4 patterns: small interfaces, accept/return, adapter, optional) - patterns/structs.md (3 patterns: zero-value, constructors, config structs) - patterns/package-design.md (3 patterns: internal/, init(), context keys) - patterns/style.md (3 patterns: interface checks, iota constants, named types) - patterns/testing-advanced.md (3 patterns: table tests, golden files, httptest) - patterns/api-conventions.md (3 patterns: Must, layered API, graceful shutdown) - patterns/documentation.md (2 patterns: examples, deprecated) - kubernetes/patterns.md (3 patterns: controller, workqueue, leader election) - kubernetes/production-go.md (2 patterns: codegen, HandleCrash) - smells/anti-patterns.md (2 anti-patterns: cache mutation, edge-triggered)
Go Patterns
Idiomatic Go patterns extracted from the Go standard library and Kubernetes source code with verified file:line citations.
Structure
patterns/— Go stdlib patterns (interfaces, errors, concurrency, structs, testing, docs, style, API conventions, packages)kubernetes/— Production-scale patterns from Kubernetes (controllers, informers, workqueues)comparison/— stdlib vs Kubernetes patternssmells/— Anti-patterns and common Go mistakeschangelog/— Daily digest of merged PRs
Philosophy
These rules are derived from what the Go source code actually does, not opinions or blog posts. Every pattern cites specific files and line numbers.
When unsure how to do something in Go, look at how the standard library does it.
Languages
Markdown
100%