| name | go-review |
| description | Reviews Go code for idioms, error handling, concurrency, and performance patterns |
| version | 1.0.0 |
| author | graycode |
| license | MIT |
| category | engineering |
| tags | ["go","review","code-quality"] |
| allowed-tools | Read Grep Glob |
Go Code Review
When to Use
- Reviewing Go code for idiomatic patterns
- Checking error handling completeness
- Auditing concurrency safety (goroutines, channels, mutexes)
- Identifying performance issues
Workflow
- Read the target files
- Check error handling: every error must be checked, no
_ = err
- Verify naming: MixedCaps, not underscores; acronyms all-caps (HTTP, ID)
- Check for goroutine leaks: every goroutine must have a shutdown path
- Verify context propagation: functions accepting context.Context as first param
- Check for unnecessary allocations in hot paths
- Ensure interfaces are small (1-3 methods)
- Verify test coverage for exported functions
Patterns
Error wrapping
return fmt.Errorf("open config: %w", err)
return err
Context propagation
func DoWork(ctx context.Context, id string) error {
func DoWork(id string) error {
Goroutine lifecycle
go func() {
select {
case <-ctx.Done():
return
case msg := <-ch:
process(msg)
}
}()
Verification
- All errors are handled or explicitly ignored with comment
- No data races (run
go vet -race)
- Exported functions have doc comments
- No
init() functions unless absolutely necessary