npx claudepluginhub jamesprial/prial-plugins --plugin golang-workflowThis skill uses the workspace's default tool permissions.
Pass `context.Context` as first parameter. Check `ctx.Done()` in goroutines and long operations.
Reviews correct Go context.Context usage: propagation, cancellation, timeouts, deadlines, values, and anti-patterns like storing in structs or passing nil. Use for context issues.
Guides context.Context usage in Go: first param in signatures, avoid storing in structs or custom types, values vs parameters, cancellation, timeouts, request-scoped data.
Guides idiomatic context.Context usage in Go: creation, propagation, cancellation, timeouts, deadlines, values, and cross-service tracing. Use when writing or refactoring Go code with contexts.
Share bugs, ideas, or general feedback.
Pass context.Context as first parameter. Check ctx.Done() in goroutines and long operations.
func ProcessItems(ctx context.Context, items []string) error {
for _, item := range items {
select {
case <-ctx.Done():
return ctx.Err()
default:
if err := processItem(item); err != nil {
return err
}
}
}
return nil
}
func main() {
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
if err := ProcessItems(ctx, items); err != nil {
log.Printf("processing failed: %v", err)
}
}
func ProcessItems(items []string) error {
for _, item := range items {
// No way to cancel - runs forever if stuck
if err := processItem(item); err != nil {
return err
}
}
return nil
}
func Do(ctx context.Context, ...)cancel() via defer to prevent leaksctx.Done() in loops and before expensive operationscontext.WithTimeout or WithDeadline for time limits// HTTP server with context
func handler(w http.ResponseWriter, r *http.Request) {
ctx := r.Context() // Request context
result, err := fetchData(ctx)
// ...
}
// Worker with cancellation
func worker(ctx context.Context) {
for {
select {
case <-ctx.Done():
return
case work := <-workCh:
process(work)
}
}
}