golang-design-patterns
golang design patterns
What it does
- Multiple init() functions run in declaration order, across files in filename alphabetical order — fragile
- Cannot return errors — failures must panic or log.Fatal
- Runs before main() and tests — side effects make tests unpredictable
- Return error: network failures, file not found, invalid input — anything a caller can handle
- Panic: nil pointer in a place that should be impossible, violated invariant, Must constructors used at init time
- .Close() / Flush() errors: read-only cleanup can often use defer f.Close(), but write/flush resources must report close or flush errors when durability matters
- Keep domain pure — no framework dependencies in the domain layer
Requirements & configuration
- Constructors SHOULD use functional options — they scale better with API evolution and require less code. Use builder pattern only if you need complex validation between configuration steps.
- Avoid repeated conversions — each one allocates. Stay in one type until you need the other.
Derived from the skill's own SKILL.md documentation · extracted 2026-07-23
golang-design-patterns FAQ
What does the golang-design-patterns skill do?
Idiomatic Golang design patterns — functional options, constructors, error flow and cascading, resource management and lifecycle, graceful shutdown, resilience, architecture, dependency injection, data handling, streaming, and more. Apply when explicitly choosing between architectural patterns, implementing functional options, designing constructor APIs, setting up graceful shutdown, applying resilience patterns, or asking which idiomatic Go pattern fits a specific problem. Multiple init() functions run in declaration order, across files in filename alphabetical order — fragile Cannot return errors — failures must panic or log.Fatal
What does golang-design-patterns require?
Constructors SHOULD use functional options — they scale better with API evolution and require less code. Use builder pattern only if you need complex validation between configuration steps. Avoid repeated conversions — each one allocates. Stay in one type until you need the other.
How do I install golang-design-patterns?
Run: npx -y skills add https://github.com/samber/cc-skills-golang --skill golang-design-patterns --agent claude-code — the source lives at github.com/samber/cc-skills-golang.
Maintain golang-design-patterns?
Let people know it's listed here — add the badge (live metrics, light/dark aware) or a plain link to your README or docs.
[](https://getagentictools.com/skills/samber-cc-skills-golang-golang-design-patterns?ref=badge) npx agentictools info skills/samber-cc-skills-golang-golang-design-patterns The second line is the CLI lookup for this page — handy in READMEs and docs.