golang

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

Updated Apr 9, 2026
One-click install
npx skills add https://github.com/5onyy/essential-ai-agent-skills --skill golang-5onyy
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: golang
Source: https://github.com/5onyy/essential-ai-agent-skills/tree/main/.cursor/skills/golang
Command: npx skills add https://github.com/5onyy/essential-ai-agent-skills --skill golang-5onyy

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Writing Go code that follows community conventions is hard without deep familiarity with the language's idioms, leading to non-idiomatic error handling, goroutine leaks, and poorly structured packages. ## Core Features & Use Cases - Idiomatic Pattern Guidance: Covers error wrapping with fmt.Errorf, errors.Is/As checks, small interfaces, functional options, and zero-value design. - Concurrency Recipes: Provides worker pools, errgroup coordination, context-based cancellation, graceful shutdown, and goroutine leak prevention. - Testing and Tooling: Includes table-driven tests, golden files, benchmarks, httptest usage, and golangci-lint configuration. - Use Case: When reviewing a Go HTTP service, apply this Skill to refactor error handling with proper wrapping, add context timeouts to outbound requests, and restructure handlers with middleware chaining. ## Quick Start Review my Go service code and refactor it to follow idiomatic Go patterns for error handling and concurrency.

Frequently Asked Questions about golang

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

FAQPage Schema
How do I handle errors idiomatically in Go?▼

Wrap errors with context using fmt.Errorf and the %w verb, then check them with errors.Is for sentinel values or errors.As for custom error types. Never ignore errors with the blank identifier unless explicitly documented.

How do I prevent goroutine leaks in Go?▼

Use buffered channels or select statements with ctx.Done() so goroutines can exit when the context is cancelled. Pair this with errgroup or sync.WaitGroup to coordinate worker completion and close channels properly.

What is the standard Go project layout?▼

Place entry points in cmd/, private application code in internal/, public libraries in pkg/, API definitions in api/, and test fixtures in testdata/. Keep package names short, lowercase, and free of underscores.

Should Go functions accept interfaces or structs?▼

Functions should accept interfaces and return concrete structs. Define interfaces in the consumer package where they are used, keeping them small and focused, often with a single method.

When should I use the functional options pattern in Go?▼

Use functional options when a constructor has many optional parameters with sensible defaults. It keeps the API clean and extensible, as shown in server configuration with WithTimeout and WithLogger options.