golang-idioms
Idiomatic Go patterns for error handling, interfaces, concurrency, testing, and module management
npx skills add rohitg00/awesome-claude-code-toolkit --skill golang-idioms --agent claude-code
Same command for any agent — swap --agent for codex, cursor, copilot.
Weekly change comes from our own snapshots, not the repository page — it measures attention, not adoption.
# Go Idioms ## Error Handling ```go // Return errors, never panic in library code func LoadConfig(path string) (Config, error) { data, err := os.ReadFile(path) if err != nil { return Config{}, fmt.Errorf("reading config %s: %w", path, err) } var cfg Config if err := json.Unmarshal(data, &cfg); err != nil { return Config{}, fmt.Errorf("parsing config: %w", err) } return cfg, nil } ``` Rules: - Always wrap errors with context using `fmt.Errorf("context: %w", err)` - Use `%w` to allow callers to use `errors.Is` and `errors.As` - Handle errors at the appropriate level; do not log and return the same error - Define sentinel errors for expected conditions ```go var ( ErrNotFound = errors.New("not found") ErrUnauthorized = errors.New("unauthorized") ) func GetUser(id string) (User, error) { user, ok := store[id] if !ok { return User{}, fmt.Errorf("user %s: %w", id, ErrNotFound) } return user, nil } // Caller user, err := GetUser(id) if errors.Is(err, ErrNotFound) { http.Error(w, "user not found", http.StatusNotFound) return } ``` ## Interface Design ```go // Keep interfaces small (1-3 methods) type Reader interface { Read(p []byte) (n int, err error) } type UserStore interface { GetUser(c
- Error Handling
- Interface Design
- Goroutine and Channel Patterns
- Worker Pool
- Fan-out/Fan-in
- Context Propagation
- Table-Driven Tests
- Test Helpers
- Module Management
- Zero-Value Design
- Structured Logging
- Common Anti-Patterns
go mod tidy # remove unused, add missing go mod verify # verify checksums go list -m -u all # check for updates go get -u ./... # update all dependencies go mod vendor # vendor dependencies (optional)
What does the golang-idioms skill do?
Idiomatic Go patterns for error handling, interfaces, concurrency, testing, and module management
How do I install it?
Run `npx skills add rohitg00/awesome-claude-code-toolkit --skill golang-idioms --agent claude-code` — it drops the skill into your project so the agent can pick it up. Swap the --agent value for codex, cursor or copilot if you use one of those.
Where does this skill come from?
From rohitg00/awesome-claude-code-toolkit, a repository with 2,438 stars. We read it straight from the repository tree rather than a submitted listing, so what you see here is what is actually published.
Is a popular skill a good skill?
Not necessarily. Stars measure attention, not adoption — a repository can trend for a week and be abandoned. That is why we show the weekly change from our own snapshots next to the total, instead of a single flattering number.