← ClaudeAtlas

go-opslisted

Go development patterns, concurrency, error handling, testing, and project structure. Use for: golang, go, goroutine, channel, context, errgroup, go test, go mod, go build, interface, generics, table-driven tests, worker pool, sync.Mutex, sync.WaitGroup, pprof, go vet, golangci-lint, go workspace, functional options, middleware, http handler.
0xDarkMatter/claude-mods · ★ 22 · AI & Automation · score 74
Install: claude install-skill 0xDarkMatter/claude-mods
# Go Operations Comprehensive Go skill covering idiomatic patterns, concurrency, and production practices. ## Module Quick Start ```bash # New module go mod init github.com/user/project # Add dependency go get github.com/lib/pq@latest # Tidy (remove unused, add missing) go mod tidy # Vendor dependencies go mod vendor # Workspace (multi-module) go work init ./api ./shared go work use ./cli ``` ## Error Handling Decision Tree ``` What kind of error? │ ���─ Known, expected condition (e.g. "not found") │ └─ Sentinel error: var ErrNotFound = errors.New("not found") │ └─ Caller checks: errors.Is(err, ErrNotFound) │ ├─ Need to carry structured data (status code, field name) │ └─ Custom error type: type ValidationError struct { Field, Message string } │ └─ Implement Error() string │ └─ Caller checks: errors.As(err, &validErr) │ ├─ Adding context to an existing error │ └─ Wrap: fmt.Errorf("load config: %w", err) │ └─ Preserves original for Is/As checks │ ├─ Truly unrecoverable (corrupted state, programmer bug) │ └─ panic("invariant violated: ...") │ └─ Almost never in library code │ └─ Multiple errors from concurrent work └─ errors.Join(err1, err2) or multierr package ``` ### Error Wrapping Convention ```go // Add context at each layer, don't repeat the function name func LoadUser(id int) (*User, error) { row, err := db.Query("SELECT ...", id) if err != nil { return nil, fmt.Errorf("load user %d: %w", id, err) } // ... } ``