language-go

Generate idiomatic Go code with error wrapping, consumer-defined interfaces, and safe concurrency patterns.

2|8|Updated Apr 20, 2026
One-click install
npx skills add https://github.com/lugassawan/swe-workbench --skill language-go-lugassawan
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: language-go
Source: https://github.com/lugassawan/swe-workbench/tree/main/skills/language-go
Command: npx skills add https://github.com/lugassawan/swe-workbench --skill language-go-lugassawan

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill helps you produce idiomatic, reliable Go code by guiding correct error handling, interface design, and concurrency patterns.

Core Features & Use Cases

  • Error handling that preserves context: Return errors instead of panicking across package boundaries, wrap with fmt.Errorf using %w, and use errors.Is/errors.As for inspection.
  • Interface and package design guidance: Define small interfaces in the consuming package and structure packages to avoid cyclic imports and vague utility packages.
  • Concurrency rules that prevent leaks: Ensure goroutines have a known termination path, use context.Context correctly, and prefer errgroup for structured concurrency.

Quick Start

Apply the Go idioms in this Skill to revise your .go code so errors wrap correctly, interfaces are consumer-defined, and goroutines are controlled with context and structured concurrency.

Frequently Asked Questions about language-go

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

FAQPage Schema
How do I handle errors in Go without losing the original error context?

To handle Go errors without losing context, return errors instead of panicking across package boundaries and wrap them using fmt.Errorf with the %w verb. You can then inspect the wrapped errors using errors.Is and errors.As for type-safe checking.

What is the best way to prevent goroutine leaks in Go concurrent workflows?

The best way to prevent goroutine leaks in Go is to ensure every goroutine has a known termination path. You should use context.Context for cancellation rules and prefer errgroup for structured concurrency to manage goroutine lifecycles safely.

How do I define interfaces in Go to avoid cyclic imports?

To avoid cyclic imports in Go, define small interfaces in the consuming package rather than the implementing package. This consumer-defined interface approach keeps package dependencies clean and prevents circular references in your library structure.

How do I propagate cancellation signals in Go services using context?

To propagate cancellation in Go services, pass context.Context as the first argument in your functions. Apply context-first cancellation rules to ensure goroutines terminate safely when the context is canceled or expires.

When should I use errgroup instead of channels for Go concurrency?

You should use errgroup over raw channels when you need structured concurrency with built-in error propagation and cancellation. Errgroup ensures goroutines terminate safely and simplifies collecting errors from concurrent workflows.