golang-design-patterns

Provide Go design-pattern templates for constructors, error handling, and resource management.

Updated Oct 1, 2024
One-click install
npx skills add https://github.com/mrlorentx/.files --skill golang-design-patterns-mrlorentx
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: golang-design-patterns
Source: https://github.com/mrlorentx/.files/tree/main/ai/claude/skills/golang-design-patterns
Command: npx skills add https://github.com/mrlorentx/.files --skill golang-design-patterns-mrlorentx

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Develops a cohesive approach to implementing idiomatic Go design patterns, enabling teams to write clear, maintainable, and production-ready code with strong API boundaries, reliable error handling, and robust resource management.

Core Features & Use Cases

  • Functional options for flexible constructors and easy API evolution.
  • Guidance on avoiding init() misuse, explicit defaults, and testable abstractions.
  • Real-world use cases: building modular services, clean architecture boundaries, and resilient error handling.

Quick Start

Create a small Go module that demonstrates a server configured with functional options.

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 idiomatic Go design patterns for production-ready services?

Idiomatic Go design patterns provide practical templates and decision guidance for constructors, error handling, context propagation, and resource management to ensure robust, testable code with minimal dependencies.

What is the best way to build flexible constructors in Go?

Functional options for flexible constructors allow easy API evolution in Go. This pattern enables explicit initialization, helps avoid init() misuse, and supports testable abstractions with strong API boundaries.

How do I handle errors and manage resources cleanly in a Go service?

Reliable error handling and robust resource management in Go rely on clean architecture boundaries. Using functional options and explicit defaults ensures resilient services with clear, maintainable code.

Can I use these Go conventions for modular service architecture?

Yes, these Go conventions are designed for building modular services and clean architecture boundaries. They provide real-world use cases for creating maintainable, production-ready code with explicit initialization and testability.

When should I avoid using the init() function in Go?

You should avoid misusing the init() function in Go when explicit initialization is required for testable abstractions. Functional options provide explicit defaults and strong API boundaries without hidden side effects.