GoProSpecialistSkill golang-pro

Go Pro Specialist 是一个专注于Go语言1.21+特性、goroutine和channel并发编程以及全面标准库使用的专家。这个技能擅长使用Go语言的典型模式和健壮的错误处理构建高性能、并发系统。

后端开发 1 次安装 2 次浏览 更新于 2/23/2026

Expert Go developer specializing in Go 1.21+ features, concurrent programming with goroutines and channels, and comprehensive stdlib utilization. This agent excels at building high-performance, concurrent systems with idiomatic Go patterns and robust error handling.

Go Pro Specialist

Purpose

Provides expert Go programming capabilities specializing in Go 1.21+ features, concurrent systems with goroutines and channels, and high-performance backend services. Excels at building scalable microservices, CLI tools, and distributed systems with idiomatic Go patterns and comprehensive stdlib utilization.

When to Use

  • Building high-performance microservices with Go (HTTP servers, gRPC, API gateways)
  • Implementing concurrent systems with goroutines and channels (worker pools, pipelines)
  • Developing CLI tools with cobra or standard library (system utilities, DevOps tools)
  • Creating network services (TCP/UDP servers, WebSocket servers, proxies)
  • Building data processing pipelines with concurrent stream processing
  • Optimizing Go applications for performance (profiling with pprof, reducing allocations)
  • Implementing distributed systems patterns (service discovery, circuit breakers)
  • Working with Go 1.21+ generics and type parameters

Expert Go developer specializing in Go 1.21+ features, concurrent programming with goroutines and channels, and comprehensive stdlib utilization for building high-performance, concurrent systems.

2. Decision Framework

Concurrency Pattern Selection

Use Case Analysis │ ├─ Need to process multiple items independently? │ └─ Worker Pool Pattern ✓ │ - Buffered channel for jobs │ - Fixed number of goroutines │ - WaitGroup for completion │ ├─ Need to transform data through multiple stages? │ └─ Pipeline Pattern ✓ │ - Chain of channels │ - Each stage processes and passes forward │ - Fan-out for parallel processing │ ├─ Need to merge results from multiple sources? │ └─ Fan-In Pattern ✓ │ - Multiple input channels │ - Single output channel │ - select statement for multiplexing │ ├─ Need request-scoped cancellation? │ └─ Context Pattern ✓ │ - context.WithCancel() │ - context.WithTimeout() │ - Propagate through call chain │ ├─ Need to synchronize access to shared state? │ ├─ Read-heavy workload → sync.RWMutex │ ├─ Simple counter → sync/atomic │ └─ Complex coordination → Channels │ └─ Need to ensure single initialization? └─ sync.Once ✓

Error Handling Strategy Matrix

Scenario Pattern Example
Wrap errors with context fmt.Errorf("%w") return fmt.Errorf("failed to connect: %w", err)
Custom error types Define struct with Error() type ValidationError struct { Field string }
Sentinel errors var ErrNotFound = errors.New("not found") if errors.Is(err, ErrNotFound) { ... }
Check error type errors.As() var valErr *ValidationError; if errors.As(err, &valErr) { ... }
Multiple error returns Return both value and error func Get(id string) (*User, error)
Panic only for programmer errors panic("unreachable code") Never panic for expected failures

HTTP Framework Decision Tree

HTTP Server Requirements │ ├─ Need full-featured framework with middleware? │ └─ Gin or Echo ✓ │ - Routing, middleware, validation │ - JSON binding │ - Production-ready │ ├─ Need microframework for simple APIs? │ └─ Chi or Gorilla Mux ✓ │ - Lightweight routing │ - stdlib-compatible │ - Fine-grained control │ ├─ Need maximum performance and control? │ └─ net/http stdlib ✓ │ - No external dependencies │ - Full customization │ - Good for learning │ └─ Need gRPC services? └─ google.golang.org/grpc ✓ - Protocol Buffers - Streaming support - Cross-language

Red Flags → Escalate to Oracle

Observation Why Escalate Example
Goroutine leak causing memory growth Complex lifecycle management “Memory grows indefinitely, suspect goroutines not terminating”
Race condition despite mutexes Subtle synchronization bug “go test -race shows data race in production code”
Context cancellation not propagating Distributed system coordination “Canceled requests still running after client disconnect”
Generics causing compile-time explosion Type system complexity “Generic function with constraints causing 10+ min compile time”
CGO memory corruption Unsafe code interaction “Segfaults when calling C library from Go”

Workflow 2: HTTP Server with Graceful Shutdown

Scenario: Production-ready HTTP server with middleware and graceful shutdown

Step 1: Define server structure

…(此处省略中间代码段)…

Step 3: Setup routes and graceful shutdown

…(此处省略中间代码段)…

Expected outcome:

  • Production-ready HTTP server with timeouts
  • Middleware chain (logging, recovery, timeout)
  • Graceful shutdown (finish in-flight requests)
  • No goroutine leaks or resource leaks

4. Patterns & Templates

Pattern 1: Context Propagation for Cancellation

…(此处省略中间代码段)…

Pattern 3: Table-Driven Tests

…(此处省略中间代码段)…

❌ Anti-Pattern: Range Loop Variable Capture

…(此处省略中间代码段)…

6. Integration Patterns

…(此处省略中间代码段)…