golang-concurrency

Analyze Go concurrency code for correctness, lifecycle, and synchronization issues.

2|Updated Mar 13, 2023
One-click install
npx skills add https://github.com/haipham22/golang-sample --skill golang-concurrency-haipham22
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: golang-concurrency
Source: https://github.com/haipham22/golang-sample/tree/main/.agents/skills/golang-concurrency
Command: npx skills add https://github.com/haipham22/golang-sample --skill golang-concurrency-haipham22

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill helps you design, review, and debug Go concurrency so goroutines exit cleanly, channels are used safely, and shared state stays race-free.

Core Features & Use Cases

  • Goroutine lifecycle control: Ensures every goroutine has a clear shutdown path through context cancellation, done signals, or waiting primitives.
  • Channel safety: Guides channel direction, ownership, closing rules, and backpressure-aware buffering decisions.
  • Synchronization decisions: Helps choose between mutexes, atomics, sync.Map, sync.Pool, sync.Once, WaitGroup, errgroup, and singleflight.
  • Pipeline and worker patterns: Supports fan-out/fan-in pipelines, bounded worker pools, and cancellation-aware stages.
  • Production hardening: Encourages panic recovery at goroutine boundaries, timer hygiene, and leak detection in tests.
  • Use case: Use this Skill when refactoring a Go service that leaks workers, deadlocks on shutdown, or needs bounded concurrent URL fetching with first-error cancellation.

Quick Start

Ask the Skill to review your Go concurrency code for leaks, race conditions, channel ownership, and the best synchronization primitive for the job.

Frequently Asked Questions about golang-concurrency

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

FAQPage Schema
How do I prevent goroutine leaks in Go concurrency code?

Analyze Go concurrency code to detect leaks by verifying proper channel ownership, context propagation, and bounded concurrency. This Skill requires leak-free shutdown paths for goroutines, channels, select loops, and worker pools.

What is the best way to choose between mutexes, atomics, and sync primitives in Go?

Choose synchronization primitives by evaluating shared-state coordination needs between mutexes, atomics, sync.Map, sync.Pool, sync.Once, WaitGroup, errgroup, and singleflight. This Skill guides safe selection to ensure race-free Go concurrency code.

How do I implement a bounded worker pool with first-error cancellation in Go?

Implement bounded worker pools using errgroup for first-error cancellation and context propagation to ensure leak-free shutdown. This Skill validates fan-out/fan-in pipelines, bounded concurrency, and cancellation-aware stages.

Why does my Go service deadlock on shutdown?

Deadlocks on shutdown occur when goroutines lack clear exit paths or channels block without close signals. This Skill analyzes channel direction, ownership, closing rules, and context propagation to resolve shutdown deadlocks.

When should I use buffered channels for backpressure in Go pipelines?

Use buffered channels for backpressure when decoupling pipeline stages requires managing data flow rates between producers and consumers. This Skill guides backpressure-aware buffering decisions alongside proper channel ownership and closing rules.

Can I use this Skill to review existing Go concurrency code for race conditions?

Yes, use this Skill to review existing Go concurrency code for race conditions, leaks, and synchronization issues. It analyzes goroutines, channels, select loops, and sync primitives to ensure safe shared-state coordination.