golang-patterns

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

Updated Feb 5, 2026
One-click install
npx skills add https://github.com/gugug168/claudecode-tutorial --skill golang-patterns-gugug168
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: golang-patterns
Source: https://github.com/gugug168/claudecode-tutorial/tree/main/everything-claude-code-learning/02-Skills/golang-patterns
Command: npx skills add https://github.com/gugug168/claudecode-tutorial --skill golang-patterns-gugug168

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Provides concise, opinionated guidance to eliminate inconsistent, non-idiomatic, or fragile Go code by teaching patterns for error handling, concurrency, interface design, package organization, and performance that reduce bugs and improve maintainability.

Core Features & Use Cases

  • Idiomatic Error Handling & Types: Recommendations for wrapping errors with context, using sentinel and custom error types, and checking errors with errors.Is and errors.As.
  • Concurrency Patterns: Worker pools, context-based cancellation, errgroup coordination, graceful shutdown, and techniques to avoid goroutine leaks.
  • Design & Organization: Advice on small focused interfaces, zero-value-friendly types, package layout (cmd/, internal/, pkg/), functional options, and embedding for composition.
  • Use Case: Use this guidance to review a microservice repository that has leaking goroutines, unclear error propagation, and package-level globals to produce concrete refactors and tests that improve stability and readability.

Quick Start

Use the golang-patterns skill to review the provided Go code and recommend idiomatic refactors that improve error handling, concurrency safety, and package structure.

Frequently Asked Questions about golang-patterns

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

FAQPage Schema
How do I handle errors in Go idiomatically using wrapping and sentinel types?

Idiomatic Go error handling involves wrapping errors with context using fmt.Errorf, defining sentinel and custom error types, and checking errors precisely with errors.Is and errors.As to improve maintainability and debugging.

What's the best way to prevent goroutine leaks in Go concurrency patterns?

Prevent goroutine leaks in Go concurrency by applying worker pools, context-based cancellation, errgroup coordination, and graceful shutdown techniques to ensure stable and robust concurrent execution.

How do I structure a Go microservice repository using cmd, internal, and pkg directories?

Structure a Go microservice repository by organizing code into cmd/ for executables, internal/ for private packages, and pkg/ for public libraries, ensuring clear separation and maintainable package organization.

When do I need to use functional options and small interfaces in Go package design?

Use functional options and small focused interfaces in Go package design when you need flexible APIs, zero-value-friendly types, and composition through embedding to create robust and readable libraries.

How to refactor Go code to fix leaking goroutines and unclear error propagation?

Refactor Go code by reviewing microservice repositories for concurrency safety, applying idiomatic error wrapping, and replacing package-level globals with structured patterns to produce concrete stability improvements.

Does this Go code review guidance integrate with standard tooling like gofmt and go vet?

Yes, Go code review guidance integrates with standard tooling like gofmt, go vet, and module management to enforce formatting, catch suspicious constructs, and ensure idiomatic codebase practices.