GoRule
by DUOMReport
Rules for Go projects: gofmt, small interfaces, wrapped errors, context everywhere, and table tests.
Developer toolsLicense: CC0-1.0Updated yesterdayrule/go
Install
Run in your project folder (DuoM CLI: risk check, then write; undo with npx duom@1 undo)
npx duom@1 add rule/go --client claude-code
Writes to CLAUDE.md in your project (where Claude Code reads it). If the project has an AGENTS.md but no CLAUDE.md, DuoM creates CLAUDE.md starting with @AGENTS.md so Claude Code keeps reading it. Only the marked block is added; the rest of the file is left alone, and remove takes out only that block.
Manual: paste into CLAUDE.md
CLAUDE.md
<!-- duom:rule/go -->
## Go
- Code is gofmt'd and passes go vet. Keep packages small and named for what they provide.
- Handle every error; wrap with fmt.Errorf("doing x: %w", err) so the cause stays checkable.
- Pass context.Context as the first argument to anything that does I/O, and respect cancellation.
- Accept interfaces, return concrete types; define interfaces where they are used.
- Write table-driven tests and run go test ./... before calling a change done.
<!-- /duom:rule/go -->The rule
Go
- Code is gofmt'd and passes go vet. Keep packages small and named for what they provide.
- Handle every error; wrap with fmt.Errorf("doing x: %w", err) so the cause stays checkable.
- Pass context.Context as the first argument to anything that does I/O, and respect cancellation.
- Accept interfaces, return concrete types; define interfaces where they are used.
- Write table-driven tests and run go test ./... before calling a change done.