npx claudepluginhub jamesprial/prial-plugins --plugin golang-workflowThis skill uses the workspace's default tool permissions.
```go
Guides Go concurrency: goroutine lifetimes with WaitGroups, channels for communication, mutexes for shared state, preventing leaks and data races.
Reviews and implements safe Go concurrency patterns: goroutines, channels, sync primitives, context propagation, lifecycle management. Use for thread safety checks, race debugging, producer/consumer pipelines.
Guides writing, reviewing, and auditing concurrent Go code using goroutines, channels, select, locks, sync primitives, errgroup, singleflight, and worker pools. Detects leaks, races, and ownership issues.
Share bugs, ideas, or general feedback.
func processBatch(items []string) {
var wg sync.WaitGroup
for _, item := range items {
wg.Add(1) // BEFORE launching goroutine
go func(item string) {
defer wg.Done()
process(item)
}(item)
}
wg.Wait() // Block until all done
}
func processBatch(items []string) {
var wg sync.WaitGroup
for _, item := range items {
go func(item string) {
wg.Add(1) // WRONG: race condition
defer wg.Done()
process(item)
}(item)
}
wg.Wait() // May return early
}
func processBatch(items []string) {
var wg sync.WaitGroup
for _, item := range items {
wg.Add(1)
go func() {
defer wg.Done()
process(item) // WRONG: captures loop variable
}()
}
wg.Wait()
}
type Counter struct {
mu sync.Mutex
value int
}
func (c *Counter) Increment() {
c.mu.Lock()
defer c.mu.Unlock()
c.value++
}
func (c *Counter) Value() int {
c.mu.Lock()
defer c.mu.Unlock()
return c.value
}
type Counter struct {
mu sync.Mutex
value int
}
func (c *Counter) Increment() {
c.mu.Lock()
c.value++ // What if panic happens?
c.mu.Unlock()
}
func (c *Counter) Value() int {
return c.value // WRONG: race condition
}
type Cache struct {
mu sync.RWMutex
data map[string]string
}
func (c *Cache) Get(key string) (string, bool) {
c.mu.RLock() // Multiple readers OK
defer c.mu.RUnlock()
val, ok := c.data[key]
return val, ok
}
func (c *Cache) Set(key, value string) {
c.mu.Lock() // Exclusive writer
defer c.mu.Unlock()
c.data[key] = value
}
Add() before go statementdefer wg.Done()Add(n) can count multiple goroutinesdefer mu.Unlock()var (
instance *Singleton
once sync.Once
)
func GetInstance() *Singleton {
once.Do(func() {
instance = &Singleton{}
})
return instance
}
go test -race ./...
go run -race main.go