Go concurrency patterns - goroutines, channels, sync primitives
View on GitHubpluginagentmarketplace/custom-plugin-go
go-development-assistant
January 21, 2026
Select agents to install to:
npx add-skill https://github.com/pluginagentmarketplace/custom-plugin-go/blob/main/skills/go-concurrency/SKILL.md -a claude-code --skill go-concurrencyInstallation paths:
.claude/skills/go-concurrency/# Go Concurrency Skill
Master Go concurrency patterns for safe, efficient parallel programming.
## Overview
Production-ready concurrency patterns including goroutines, channels, sync primitives, and common pitfalls to avoid.
## Parameters
| Parameter | Type | Required | Default | Description |
|-----------|------|----------|---------|-------------|
| pattern | string | yes | - | Pattern: "worker-pool", "fan-out", "pipeline", "semaphore" |
| workers | int | no | runtime.NumCPU() | Number of concurrent workers |
| buffer_size | int | no | 0 | Channel buffer size |
## Core Topics
### Goroutines with Context
```go
func ProcessItems(ctx context.Context, items []Item) error {
g, ctx := errgroup.WithContext(ctx)
for _, item := range items {
item := item // capture loop variable
g.Go(func() error {
select {
case <-ctx.Done():
return ctx.Err()
default:
return process(item)
}
})
}
return g.Wait()
}
```
### Worker Pool
```go
func WorkerPool[T, R any](ctx context.Context, workers int, jobs <-chan T, fn func(T) R) <-chan R {
results := make(chan R, workers)
var wg sync.WaitGroup
for i := 0; i < workers; i++ {
wg.Add(1)
go func() {
defer wg.Done()
for {
select {
case <-ctx.Done():
return
case job, ok := <-jobs:
if !ok {
return
}
results <- fn(job)
}
}
}()
}
go func() {
wg.Wait()
close(results)
}()
return results
}
```
### Rate Limiter
```go
type RateLimiter struct {
tokens chan struct{}
}
func NewRateLimiter(rate int, interval time.Duration) *RateLimiter {
rl := &RateLimiter{
tokens: make(chan struct{}, rate),
}
go func() {
ticker := time.NewTicker