# golang-design-patterns

> Claude/Codex skill by [@samber](https://omgskills.com/library/samber/index.md) · 2.8k stars · 39k installs · Updated 2026-08-01

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.

Tags: agent, agent-skills, ai, antigravity, claude, claude-code, code, codex, coding, copilot, cursor, gemini, gemini-cli-extension, openclaw, opencode, plugin, skills, skillsmp, vibe-coding

## Install

```sh
git clone https://github.com/samber/cc-skills-golang /tmp/cc-skills-golang && ln -s /tmp/cc-skills-golang/skills/golang-design-patterns ~/.claude/skills/golang-design-patterns
```

## From README

Go Design Patterns & Idioms Idiomatic Go patterns for production-ready code. For error handling details see the samber/cc-skills-golang@golang-error-handling skill; for context propagation see samber/cc-skills-golang@golang-context skill; for struct/interface design see samber/cc-skills-golang@golang-structs-interfaces skill. Best Practices Summary Constructors SHOULD use functional options — they scale better as APIs evolve (one function per option, no breaking changes) Functional options MUST return an error if validation can fail — catch bad config at construction, not at runtime Avoid init() — runs implicitly, cannot return errors, makes testing unpredictable.

## Links

- HTML page: https://omgskills.com/skills/samber/cc-skills-golang/golang-design-patterns/
- GitHub: https://github.com/samber/cc-skills-golang
- Author: [@samber](https://omgskills.com/library/samber/index.md)

## More from this repo

- [golang-google-wire](https://omgskills.com/skills/samber/cc-skills-golang/skills/golang-google-wire/index.md) — Compile-time dependency injection in Golang using google/wire — wire.NewSet, wire.Build, wire.Bind...
   - [@samber](https://omgskills.com/library/samber/index.md) · 3.1k stars
- [golang-gopls](https://omgskills.com/skills/samber/cc-skills-golang/skills/golang-gopls/index.md) — Golang semantic code intelligence via \`gopls\`, the official Go language server — go-to-definition, find references,...
   - [@samber](https://omgskills.com/library/samber/index.md) · 3k stars
- [golang-how-to](https://omgskills.com/skills/samber/cc-skills-golang/skills/golang-how-to/index.md) — Golang skills orchestrator — always active on any Golang coding, review, debug, or setup task.
   - [@samber](https://omgskills.com/library/samber/index.md) · 3k stars
