← ClaudeAtlas

language-golisted

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.
lugassawan/swe-workbench · ★ 2 · Code & Development · score 68
Install: claude install-skill lugassawan/swe-workbench
# Go ## Errors are values - Return `error`; do not `panic` across package boundaries. - Wrap with `fmt.Errorf("doing X: %w", err)` to preserve the chain. - Inspect with `errors.Is` and `errors.As`. Never string-match messages. - Sentinel errors (`var ErrNotFound = errors.New(...)`) for expected cases; typed errors when callers need structured data. ```go if err != nil { return fmt.Errorf("load user %s: %w", id, err) } ``` ## Interfaces — small, defined by the consumer - Define interfaces in the package that *uses* them, not where concrete types live. - Single-method interfaces are normal (`io.Reader`, `io.Closer`). - Accept interfaces, return concrete types. ## Concurrency - A goroutine without a known termination path is a leak. Always know who stops it. - `context.Context` plumbs cancellation and deadlines — first parameter, named `ctx`. - Channels for ownership transfer; mutexes for protecting state. A `sync.Mutex` is often simpler than a goroutine. - `errgroup.Group` for structured concurrency with error propagation. ```go 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 } ``` ## Context rules - `ctx` is the first parameter of any blocking or IO function. - Never store `context.Context` in a struct field. - Don't use `context.Value` for required parameters — only cross-cutting concerns like request IDs. ## Tests - Table-driven tests are