Claude-skill-registry go-patterns
This skill should be used for Go idioms, error handling, goroutines, interfaces, and testing, golang, Go language, Go modules, Go concurrency
install
source · Clone the upstream repo
git clone https://github.com/majiayu000/claude-skill-registry
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/majiayu000/claude-skill-registry "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/data/go-patterns" ~/.claude/skills/majiayu000-claude-skill-registry-go-patterns && rm -rf "$T"
manifest:
skills/data/go-patterns/SKILL.mdsource content
Go Patterns
Idiomatic Go patterns for Go 1.21+.
Error Handling
if err != nil { return fmt.Errorf("failed to process %s: %w", id, err) }
Interfaces
Small interfaces (1-3 methods). Accept interfaces, return structs.
type Reader interface { Read(p []byte) (n int, err error) }
Table-Driven Tests
tests := []struct{ name string input, want int }{ {"positive", 2, 3}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { if got := Fn(tt.input); got != tt.want { t.Errorf("got %d, want %d", got, tt.want) } }) }
Concurrency
Always propagate context for cancellation:
func work(ctx context.Context) error { select { case <-ctx.Done(): return ctx.Err() default: // do work } }
Defer for Cleanup
f, err := os.Open(path) if err != nil { return err } defer f.Close()