golang-design-patterns

Recommend idiomatic Go design patterns for constructors, error flow, and graceful shutdown.

Updated May 28, 2026
One-click install
npx skills add https://github.com/vanstinator/semantic-search --skill golang-design-patterns-vanstinator
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: golang-design-patterns
Source: https://github.com/vanstinator/semantic-search/tree/main/.agents/skills/golang-design-patterns
Command: npx skills add https://github.com/vanstinator/semantic-search --skill golang-design-patterns-vanstinator

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

It helps you implement or review production-ready Go code using idiomatic design patterns while avoiding common pitfalls like premature abstraction, init() side effects, and leaky resource management.

Core Features & Use Cases

  • Design mode: Guides API and application structure choices (constructors, functional options, graceful shutdown, resilience, and dependency injection).
  • Review mode: Audits existing code for design and reliability issues such as init() abuse, missing timeouts, implicit global state, and unbounded resource use.
  • Idiomatic Go standards: Enforces practical rules for error flow, resource lifecycle, streaming large data, and safe concurrency boundaries.

Quick Start

Ask an AI to propose the smallest idiomatic Go constructor API using functional options for a service that needs graceful shutdown, timeouts, and bounded resource limits.

Frequently Asked Questions about golang-design-patterns

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I implement functional options in Go constructors to avoid init() side effects?

Structure Go constructors using explicit initialization and dependency injection instead of init() side effects. Validate configuration at construction time using functional options to enforce safe boundaries and ensure operational reliability within your packages.

What is the best way to handle graceful shutdown and resilience in production Go services?

Handle graceful shutdown and resilience in Go services by enforcing context-aware retries, explicit timeouts, and bounded resource limits. Planning resource lifecycle management prevents unbounded resource use and ensures safe concurrency boundaries during operational stress.

How do I enforce error-flow conventions and prevent leaky resource management in Golang?

Enforce Golang error-flow conventions by validating resources at construction time and applying correct data handling patterns. Using explicit constructors and streaming patterns for large data prevents leaky resource management and eliminates implicit global state.

Can I use this to review existing Go code for design and reliability issues?

Yes, you can review existing Go code for design and reliability issues like init() abuse, missing timeouts, implicit global state, and unbounded resource use. This audit mode identifies operational reliability risks and suggests idiomatic design pattern improvements.

Why should I avoid premature abstraction when designing Go package APIs?

Avoid premature abstraction when designing Go package APIs to maintain simple, idiomatic code structures. Favoring explicit constructors, dependency injection, and functional options prevents leaky resource management and ensures practical error-flow conventions.