Golang Pro
Idiomatic Go 1.21+, concurrency, and cloud-native microservices.
When to use
Concurrent programming (goroutines/channels); gRPC or REST microservices; generics; interface-driven design; pprof performance work; CLI tools; benchmarks/fuzzing.
Core workflow
- Analyze — module structure, interfaces, concurrency patterns.
- Design interfaces — small, focused, composed.
- Implement — idiomatic Go, error handling, context propagation;
go vet ./....
- Lint —
golangci-lint run, fix all.
- Optimize — pprof, benchmarks, fewer allocations.
- Test — table-driven with
-race, fuzzing, 80%+ coverage.
Key pattern
// Bounded goroutine with context cancellation + error propagation
func worker(ctx context.Context, jobs <-chan Job, errCh chan<- error) {
for {
select {
case <-ctx.Done():
errCh <- fmt.Errorf("worker cancelled: %w", ctx.Err()); return
case job, ok := <-jobs:
if !ok { return } // channel closed; clean exit
if err := process(ctx, job); err != nil {
errCh <- fmt.Errorf("process %v: %w", job.ID, err); return
}
}
}
}
Properties: bounded lifetime via ctx, %w error wrapping, no goroutine leak on cancel.
Constraints
MUST: gofmt + golangci-lint; context.Context on blocking ops; handle all errors explicitly; table-driven tests with subtests; doc all exported symbols; wrap errors with %w; run -race.
MUST NOT: ignore errors (_ without reason); panic for normal errors; spawn goroutines without lifecycle; skip context cancellation; reflection without justification; hardcode config (use functional options/env).
Output
- Interface definitions (contracts first). 2. Implementation with package structure. 3. Table-driven tests. 4. Brief note on concurrency patterns.
Knowledge
Go 1.21+, goroutines, channels, select, sync, generics/constraints, io.Reader/Writer, gRPC, context, error wrapping, pprof, benchmarks, fuzzing, go.mod, internal packages, functional options.
1---2name: golang-pro3description: "Use when building Go 1.21+ applications with concurrent goroutine/channel patterns, gRPC or REST microservices, generics, or high-performance systems. Triggers: Go, Golang, goroutines, channels, gRPC, microservices Go, Go generics, concurrent programming, Go interfaces, pprof."4version: 1.0.05license: MIT6tags: [go, golang, goroutines, channels, grpc, generics, microservices, pprof]7source: https://github.com/jeffallan/claude-skills/tree/main/skills/golang-pro8derived_from: awesomeclaude9metadata:10 source: https://skillmd.com/skills/aashutosh396/golang-pro11---1213# Golang Pro1415Idiomatic Go 1.21+, concurrency, and cloud-native microservices.1617## When to use1819Concurrent programming (goroutines/channels); gRPC or REST microservices; generics; interface-driven design; pprof performance work; CLI tools; benchmarks/fuzzing.2021## Core workflow22231. **Analyze** — module structure, interfaces, concurrency patterns.242. **Design interfaces** — small, focused, composed.253. **Implement** — idiomatic Go, error handling, context propagation; `go vet ./...`.264. **Lint** — `golangci-lint run`, fix all.275. **Optimize** — pprof, benchmarks, fewer allocations.286. **Test** — table-driven with `-race`, fuzzing, 80%+ coverage.2930## Key pattern3132```go33// Bounded goroutine with context cancellation + error propagation34func worker(ctx context.Context, jobs <-chan Job, errCh chan<- error) {35 for {36 select {37 case <-ctx.Done():38 errCh <- fmt.Errorf("worker cancelled: %w", ctx.Err()); return39 case job, ok := <-jobs:40 if !ok { return } // channel closed; clean exit41 if err := process(ctx, job); err != nil {42 errCh <- fmt.Errorf("process %v: %w", job.ID, err); return43 }44 }45 }46}47```4849Properties: bounded lifetime via ctx, `%w` error wrapping, no goroutine leak on cancel.5051## Constraints5253MUST: gofmt + golangci-lint; context.Context on blocking ops; handle all errors explicitly; table-driven tests with subtests; doc all exported symbols; wrap errors with `%w`; run `-race`.54MUST NOT: ignore errors (`_` without reason); panic for normal errors; spawn goroutines without lifecycle; skip context cancellation; reflection without justification; hardcode config (use functional options/env).5556## Output57581. Interface definitions (contracts first). 2. Implementation with package structure. 3. Table-driven tests. 4. Brief note on concurrency patterns.5960## Knowledge6162Go 1.21+, goroutines, channels, select, sync, generics/constraints, io.Reader/Writer, gRPC, context, error wrapping, pprof, benchmarks, fuzzing, go.mod, internal packages, functional options.