Stats
Actions
Tags
From swe-workbench
Go idioms — error handling, concurrency, and standard library usage. Auto-load when working with .go files, go.mod, go.sum, or when the user mentions Go, Golang, goroutines, channels, interfaces, context, or error wrapping.
How this skill is triggered — by the user, by Claude, or both
Slash command
/swe-workbench:language-goThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
- Return `error`; do not `panic` across package boundaries.
error; do not panic across package boundaries.fmt.Errorf("doing X: %w", err) to preserve the chain.errors.Is and errors.As. Never string-match messages.var ErrNotFound = errors.New(...)) for expected cases; typed errors when callers need structured data.if err != nil {
return fmt.Errorf("load user %s: %w", id, err)
}
io.Reader, io.Closer).context.Context plumbs cancellation and deadlines — first parameter, named ctx.sync.Mutex is often simpler than a goroutine.errgroup.Group for structured concurrency with error propagation.g, ctx := errgroup.WithContext(ctx)
for _, job := range jobs {
job := job
g.Go(func() error { return process(ctx, job) })
}
if err := g.Wait(); err != nil { return err }
ctx is the first parameter of any blocking or IO function.context.Context in a struct field.context.Value for required parameters — only cross-cutting concerns like request IDs.t.Run(name, ...) for subtests.t.Cleanup beats defer for shared fixtures.httptest.Server for HTTP; testing/iotest for edge IO.for _, c := range cases {
t.Run(c.name, func(t *testing.T) {
if got := Add(c.a, c.b); got != c.want {
t.Errorf("Add(%d,%d) = %d, want %d", c.a, c.b, got, c.want)
}
})
}
util, common, helpers. Name by the domain thing it owns.if err := do(); err != nil { ... } — keep errors close to their cause.defer for cleanup; defer in a loop accumulates.any over interface{} in new code.slices, maps, cmp from stdlib over hand-rolled helpers.panic as flow control.npx claudepluginhub lugassawan/swe-workbench --plugin swe-workbenchGuides creation, editing, and verification of skills for AI coding agents using test-driven development with subagent scenarios. Use when authoring or debugging skills.