Go best practices
Plugin with opinionated set of Claude Code agents nad skills
npx -y skills add lklimek/claudius --skill go-best-practicesAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
One thing to look at
- 1 stars1 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
What its author says it does
Copied from the file, not written here
Go best practices — idioms, error handling, concurrency, testing patterns. Use when writing, reviewing, or discussing Go code.
SKILL.md
3.1 KB, as published. Nobody here has run it
Go Best Practices
Technical Standards
- Go Version: 1.21+ (or latest stable)
- Code Style: gofmt/goimports enforced
- Linting: golangci-lint with comprehensive checks
- Testing: go test with table-driven tests
- Documentation: One-line Godoc comment for every exported identifier; expand only when non-obvious
- Error Handling: Explicit with error wrapping (fmt.Errorf with %w)
- Modules: Go modules for dependency management
- Context: context.Context for cancellation and timeouts
Best Practices
- Accept interfaces, return structs
- Keep interfaces small (single-method often best)
- Use context.Context for cancellation propagation
- Always check errors — don't ignore with
_ - Use defer for cleanup (close files, unlock mutexes)
- Goroutines: always know when they exit
- Channels for communication, mutexes for state
- Prefer composition over embedding
- Use
internal/package for private code - Prefer standard library first
Common Patterns
- Error Wrapping:
fmt.Errorf("context: %w", err) - Options Pattern: Functional options for constructors
- Context: Pass as first parameter
- Interfaces: io.Reader, io.Writer, io.Closer patterns
- Middleware: Handler wrapping for HTTP servers
- Worker Pools: Channel-based task distribution
- Graceful Shutdown: Signal handling with context cancellation
Concurrency
- Use sync.WaitGroup to wait for goroutines
- Use buffered channels carefully — understand blocking
- Use select for channel multiplexing
- Implement worker pools for bounded concurrency
Error Handling
- Define custom error types for sentinel errors
- Use errors.Is() and errors.As() for checking
- Return errors as last return value
- Don't panic in library code — return errors
- Log errors at the right level in the call stack
Code Quality Tools
- Formatting: gofmt, goimports
- Linting: golangci-lint (staticcheck, errcheck, govet, etc.)
- Testing:
go test -race -cover ./... - Security: gosec
- Dependencies:
go mod tidy,go mod verify - Benchmarks:
go test -bench=. -benchmem
Common Pitfalls
- Don't use global variables excessively
- Don't use init() unless absolutely necessary
- Don't over-use interfaces early — add when needed
Code Review Checklist
- Idiomatic Go style (Effective Go compliance)
- Error handling: explicit checks, no ignored errors, proper wrapping with %w
- Goroutine lifecycle: clear start/stop, no leaks
- Interface design: small, focused, used appropriately
- Context propagation for cancellation
- Defer usage for cleanup
- DRY compliance: duplicated logic, copy-paste patterns
- Naming clarity: exported vs unexported, package naming
- Test quality: table-driven tests, meaningful assertions, race condition coverage
- Code brevity: flag code that can be expressed in fewer lines without losing clarity
Use GO-NNN prefix for all findings.