golang

Implements idiomatic Go applications with concurrency, testing, profiling, and HTTP patterns.

1|Updated Mar 27, 2026
One-click install
npx skills add https://github.com/lrstanley/skills --skill golang-lrstanley
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: golang
Source: https://github.com/lrstanley/skills/tree/main/golang
Command: npx skills add https://github.com/lrstanley/skills --skill golang-lrstanley

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Writing production-grade Go requires deep knowledge of concurrency patterns, error handling, generics, testing, and observability. This Skill provides expert-level guidance and reference material so Go code is idiomatic, race-free, and well-documented from the start. ## Core Features & Use Cases - Concurrency & Error Patterns: Apply goroutine lifecycle management, channels, semaphores, context cancellation, and error wrapping with errors.Is/As and errors.Join. - Testing & Performance: Write table-driven tests with the race detector, benchmarks with benchstat comparison, and pprof profiling for CPU, heap, and goroutine leaks. - HTTP & CLI Development: Build servers with chi/chix middleware stacks, resilient HTTP clients with retry/logging/caching transports, and CLI tools with clix/kong flag parsing. - Use Case: When asked to build a Go microservice, the Skill loads the relevant references to produce an HTTP server with structured logging, graceful shutdown, table-driven tests, and proper context propagation. ## Quick Start Ask the agent to implement a Go HTTP API with middleware, structured logging, and table-driven tests using the golang skill.

Frequently Asked Questions about golang

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

FAQPage Schema
How do I write idiomatic Go code with proper error handling?▼

Wrap errors at each layer with fmt.Errorf and %w, match sentinels with errors.Is, and extract typed errors with errors.AsType. Keep error strings lowercase without punctuation, and use errors.Join to combine independent failures.

How to prevent goroutine leaks in Go applications?▼

Give every goroutine a bounded lifetime using context cancellation, buffered channels, or draining receivers. Diagnose confirmed leaks with the goroutineleak pprof profile and run tests with the -race flag.

What Go version features does this skill cover?▼

It targets Go 1.27+, including generic methods, errors.AsType, testing/synctest, encoding/json/v2, built-in min/max, and range-over-int loops. Legacy patterns like loop variable capture workarounds are flagged as unnecessary on Go 1.22+.

Should I use encoding/json or encoding/json/v2 in new Go code?▼

Use encoding/json/v2 for all new code; existing v1 call sites are fine to leave unchanged. The v2 package provides improved performance and a modern Options-based API for marshaling and unmarshaling.

How do I compare Go benchmark results before and after a change?▼

Run benchmarks with -benchmem and -count=10, saving output before and after the change, then compare with benchstat. A result marked with ~ means the difference is indistinguishable from noise.

When should I not use panic in Go error handling?▼

Never use panic for expected failures like network timeouts or missing files; return errors instead. Panic is only acceptable for programmer errors, impossible conditions, or corrupt invariants such as MustCompile-style initialization.