From Go Expert
Expert idiomatic Go: concurrency, interfaces, error handling, and the standard library. Trigger keywords: Go, golang, goroutine, channel, context, select, interface, error wrapping, errors.Is, defer, sync, Mutex, WaitGroup, errgroup, race, pprof. Use for writing/refactoring Go, designing concurrency, or fixing races, leaks, and deadlocks.
How this skill is triggered — by the user, by Claude, or both
Slash command
/go-expert:go-expertThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
> Clear is better than clever. Handle every error explicitly, make the zero value useful, and give every goroutine an owner and an exit. "Share memory by communicating," but a `Mutex` is fine for protecting state.
Clear is better than clever. Handle every error explicitly, make the zero value useful, and give every goroutine an owner and an exit. "Share memory by communicating," but a
Mutexis fine for protecting state.
context, select).software-architect.if err != nil { return fmt.Errorf("doing X: %w", err) }. Wrap with %w to preserve the chain; inspect with errors.Is (sentinel) / errors.As (typed).sync.Mutex, bytes.Buffer work unboxed). Use defer for cleanup (close/unlock) right after acquisition.sync.WaitGroup or errgroup to wait, and bound concurrency (errgroup.SetLimit, worker pool, semaphore).context.Context is the first parameter for anything cancelable/IO-bound; honor ctx.Done(). Never store a Context in a struct.Mutex for protecting shared state. Close a channel from the sender, once. Prefer select with ctx for cancelable waits.gofmt (non-negotiable), go vet, golangci-lint. Always test concurrent code with -race.internal/. Avoid premature interfaces and needless abstraction.for i, v := range needed i, v := i, v; fixed in Go 1.22+, but know your version._ = f()) or only logging without returning.ctx that never fires — always provide cancellation.WaitGroup.Add inside the goroutine → race; call Add before go.Mutex or use sync.Map for the right pattern.err != nil is true unexpectedly (typed-nil trap).Bounded concurrency with errgroup + context
func fetchAll(ctx context.Context, urls []string) ([]string, error) {
g, ctx := errgroup.WithContext(ctx)
g.SetLimit(10) // cap concurrency
out := make([]string, len(urls))
for i, u := range urls { // Go 1.22+: no manual capture needed
i, u := i, u
g.Go(func() error {
req, _ := http.NewRequestWithContext(ctx, http.MethodGet, u, nil)
resp, err := http.DefaultClient.Do(req)
if err != nil {
return fmt.Errorf("get %s: %w", u, err)
}
defer resp.Body.Close()
b, err := io.ReadAll(resp.Body)
out[i] = string(b)
return err
})
}
return out, g.Wait() // first error cancels the rest via ctx
}
Sentinel error inspection
if errors.Is(err, sql.ErrNoRows) { return nil, ErrNotFound }
performance-expert — pprof, escape analysis, allocation reduction.testing-expert — table-driven tests and -race.docker-expert — tiny static images (FROM scratch/distroless).rust-expert — alternative ownership-based concurrency model.Creates, edits, and optimizes skills for Claude Code, including drafting, evaluating with test prompts, iterating on performance, and improving skill descriptions for better triggering accuracy.
npx claudepluginhub miaoge-ge/coding-agent-skills --plugin go-expert