go

Review production Go code for error handling, context propagation, and goroutine management.

13|Updated Mar 15, 2019
One-click install
npx skills add https://github.com/WTFox/dotfiles --skill go-wtfox
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: go
Source: https://github.com/WTFox/dotfiles/tree/main/claude/.claude/skills/go
Command: npx skills add https://github.com/WTFox/dotfiles --skill go-wtfox

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This skill consolidates best practices for production Go code and prevents common Claude-generated mistakes such as missing context, unwrapped errors, goroutine leaks, and poor project structure.

Core Features & Use Cases

  • Error handling: always wrap with context and propagate actionable errors.
  • Context propagation: ensure context.Context is passed through the call chain.
  • Goroutines: encourage lifecycles that prevent leaks and use structured concurrency.
  • Project layout & interfaces: encourage small, use-at-point interfaces and standard repository patterns.
  • Testing guidance: promote table-driven tests and robust error checking.

Quick Start

Load this skill before writing or reviewing Go code in production to apply the patterns described above.

Frequently Asked Questions about go

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

FAQPage Schema
How do I fix goroutine leaks in my Go production code?

Fix goroutine leaks in Go production code by implementing structured concurrency with explicit lifecycle controls. This ensures goroutines terminate properly when their parent operations complete, preventing resource leaks and unexpected behavior.

What is the correct way to propagate context.Context through a Go service?

Propagate context.Context through a Go service by passing it as the first parameter in function signatures. This pattern maintains cancellation signals and timeouts across the entire call chain, ensuring reliable context propagation in HTTP handlers and services.

Why does my Go error handling lose stack trace and context information?

Go error handling loses context when errors are returned unwrapped. Always wrap errors with contextual information using error wrapping patterns to propagate actionable diagnostics up the call chain for effective debugging.

How do I structure table-driven tests for Go HTTP handlers?

Structure table-driven tests for Go HTTP handlers by defining test cases in slices with input arguments and expected outcomes, then iterating through them to execute robust error checking and validate handler behavior comprehensively.

Can I use small interfaces for testable Go project layouts?

Yes, use small, use-at-point interfaces to build testable Go project layouts. Defining interfaces where they are consumed rather than at package boundaries ensures components remain decoupled, mockable, and aligned with standard repository patterns.

What are common Go production patterns that cause context and error issues?

Common Go production patterns causing issues include missing context propagation, unwrapped errors, unmanaged goroutine lifecycles, and poor project structure. Identifying and fixing these patterns prevents leaks and ensures clear, actionable error reporting.