go-concurrency

Coordinate goroutines, channels, and sync primitives in Go programs.

187|20|Updated Nov 20, 2025
One-click install
npx skills add https://github.com/TheBushidoCollective/han --skill go-concurrency-thebushidocollective
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: go-concurrency
Source: https://github.com/TheBushidoCollective/han/tree/main/jutsu/jutsu-go/skills/go-concurrency
Command: npx skills add https://github.com/TheBushidoCollective/han --skill go-concurrency-thebushidocollective

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Master Go's concurrency model using goroutines, channels, and synchronization primitives for scalable programs.

Core Features & Use Cases

  • Spawning goroutines and coordinating with channels
  • Worker pools and synchronization primitives (WaitGroup, Mutex)
  • Safe concurrent patterns and avoiding data races

Quick Start

Launch a simple goroutine that sends data over a channel and coordinate with a receiver.

Frequently Asked Questions about go-concurrency

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

FAQPage Schema
How do I build concurrent applications with goroutines and channels in Go?

Goroutines are lightweight threads managed by the Go runtime; launch them with the `go` keyword. Channels enable safe communication between goroutines. Use unbuffered channels for synchronization, buffered channels for queuing, and the `select` statement to multiplex multiple channel operations. Coordinate completion with `WaitGroup` or channel closing semantics.

What's the best way to implement worker pools in Go?

Worker pools use goroutines that receive tasks from a channel, process them, and signal completion. Spawn a fixed number of worker goroutines, send work through an input channel, collect results on an output channel, and use `WaitGroup` to wait for all workers to finish. This pattern prevents goroutine explosion and controls resource usage.

How do I safely share state between goroutines?

Avoid data races by either using channels to communicate ownership or by protecting shared data with synchronization primitives. `Mutex` locks critical sections for exclusive access; `RWMutex` allows concurrent reads with exclusive writes; `Once` ensures one-time initialization. Choose based on contention patterns and access frequency.

Can I use channels to handle timeouts in Go?

Yes. Use `time.After()` or `time.Tick()` to create timeout channels, then combine them with `select` to handle both completion and timeout cases. This pattern prevents goroutines from blocking indefinitely and enables graceful degradation when operations exceed acceptable time limits.

When should I use buffered vs. unbuffered channels?

Unbuffered channels synchronize goroutines—the sender blocks until a receiver is ready. Buffered channels queue messages up to their capacity, allowing senders to proceed without an immediate receiver. Use unbuffered for tight coordination, buffered when you need decoupling or producer-consumer rate differences.

What happens if I don't close channels properly?

Failing to close a channel leaves goroutines waiting indefinitely, causing deadlocks or resource leaks. Close channels only from the sender side once no more values will be sent. Receivers can distinguish closure from values using the comma-ok idiom. Synchronization primitives like `WaitGroup` help coordinate clean shutdown.