go-concurrency

Detect unsafe Go concurrency patterns and prevent goroutine leaks.

8|Updated Jun 5, 2026
One-click install
npx skills add https://github.com/muratmirgun/gophers --skill go-concurrency-muratmirgun
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: go-concurrency
Source: https://github.com/muratmirgun/gophers/tree/main/skills/go-concurrency
Command: npx skills add https://github.com/muratmirgun/gophers --skill go-concurrency-muratmirgun

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill helps you design, review, and fix concurrent Go code so goroutines stop cleanly, shared state is protected correctly, and cancellation works predictably.

Core Features & Use Cases

  • Structured concurrency: Choose the right primitive for goroutines, worker pools, fan-out/fan-in pipelines, and first-error cancellation.
  • Ownership-safe channels: Apply channel direction, sender-only closing, and ctx-aware select loops to avoid leaks and panics.
  • Shared-state guidance: Decide between mutexes, atomics, sync.Map, sync.Once, sync.Pool, and singleflight for the right concurrency pattern.
  • Verification and testing: Add leak checks with goleak, deterministic timing with synctest, and race-safe validation for production-grade code.
  • Use case: Review a Go service that spawns background workers and ensure every goroutine has a stop path, every channel has a clear owner, and every critical section is safe.

Quick Start

Ask for a review of your Go concurrency code and have it checked for goroutine leaks, unsafe channel usage, and the correct synchronization primitive.

Frequently Asked Questions about go-concurrency

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

FAQPage Schema
How do I detect and prevent goroutine leaks in Go?

Prevent goroutine leaks by applying structured cancellation, ensuring every goroutine has a clear stop path, and verifying cleanup deterministically using goleak tests in your Go concurrency code.

What is the safest way to close channels in Go concurrency?

The safest channel closing approach is sender-owned closing, where only the sending goroutine closes the channel, combined with context-aware select loops to prevent panics and unsafe channel misuse.

When should I use mutexes vs atomics for shared state in Go?

Choose mutexes for complex critical sections, and atomics for simple counter or flag updates, while also evaluating sync.Map, sync.Once, sync.Pool, and singleflight for specific Go concurrency patterns.

How do I implement first-error cancellation in Go worker pools?

Implement first-error cancellation in Go worker pools by using errgroup workflows, which provide bounded concurrency and automatically cancel remaining goroutines when the first error occurs.

Can I test Go concurrency timing deterministically without flaky sleeps?

Test Go concurrency timing deterministically using synctest, which allows you to control and verify goroutine scheduling and timing behavior without relying on flaky sleep calls.

Why does my Go service hang on channel send operations?

Channel sends hang when receivers are missing or cancellation fails; fix this by applying channel direction constraints, context-aware select loops, and ensuring senders own the channel lifecycle.