golang-patterns

Provide idiomatic Go patterns for error handling, concurrency, and design.

10|3|Updated Apr 3, 2012
One-click install
npx skills add https://github.com/liuerfire/dotfiles --skill golang-patterns-liuerfire
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: golang-patterns
Source: https://github.com/liuerfire/dotfiles/tree/main/agentic/skills/golang-patterns
Command: npx skills add https://github.com/liuerfire/dotfiles --skill golang-patterns-liuerfire

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill provides guidance on writing clean, efficient, and maintainable Go code by illustrating idiomatic patterns and best practices.

Core Features & Use Cases

  • Idiomatic Go: Learn and apply standard Go conventions for error handling, concurrency, and design.
  • Best Practices: Understand principles like simplicity, useful zero values, and interface design.
  • Use Case: When starting a new Go project or refactoring existing code, consult this Skill to ensure your implementation adheres to Go's established best practices, leading to more robust and understandable software.

Quick Start

Show me the idiomatic Go pattern for handling errors with context.

Frequently Asked Questions about golang-patterns

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

FAQPage Schema
What is the best way to handle errors in idiomatic Go?

Idiomatic Go error handling involves wrapping errors with context using standard conventions and custom error types. This approach ensures robust and maintainable applications by preserving the error chain while adding meaningful context for easier debugging.

How do I implement concurrency patterns like worker pools in Go?

You can implement concurrency patterns in Go by utilizing worker pools and errgroups. These idiomatic patterns manage concurrent operations efficiently, ensuring robust synchronization, controlled parallelism, and proper error propagation across multiple goroutines.

When should I use functional options for struct design in Go?

You should use functional options for struct design in Go when you need highly configurable and maintainable structures. This idiomatic pattern provides flexible APIs by passing configuration functions, allowing you to set optional parameters while ensuring useful zero values by default.

How do I organize packages and interfaces for maintainable Go code?

Organize Go packages and interfaces by adhering to principles of simplicity and defining small, focused interfaces. This idiomatic approach ensures clean architecture, reduces dependencies, and produces highly maintainable and efficient Go applications.

Does this guidance cover memory and performance optimizations for Go?

This guidance covers memory and performance optimizations alongside Go tooling integration. It helps you write efficient applications by applying idiomatic patterns that reduce allocations and leverage standard Go tools to profile and maintain robust codebases.