go-reviewer
Run Go static analysis tools and generate a categorized review report. Use before committing or creating PRs for Go code.
Go Code Review
MANDATORY: You MUST use the Bash tool to run actual commands and the Read tool to read actual files BEFORE producing any analysis. Do NOT guess, infer, or fabricate code content or tool output. If a tool call fails, report the failure — do not invent a result.
Run all Go static analysis tools on changed files, categorize issues by severity, and provide a clear verdict.
Process
Step 1: Identify scope
If the task specifies a target path, use it. Otherwise, find changed .go files:
git diff --name-only --diff-filter=d HEAD | grep '\.go$'
If no changed files found, run against ./....
Step 2: Run analysis tools (in order, do not stop on failure)
1. go vet
go vet ./...
2. staticcheck
staticcheck ./...
3. golangci-lint
golangci-lint run ./...
4. Race detection (build only, no execution)
go build -race ./... 2>&1
5. Vulnerability scan
govulncheck ./...
Step 3: Categorize issues
Classify every issue found:
| Severity | Examples |
|---|---|
| CRITICAL | Race conditions, SQL/command injection, goroutine leaks, hardcoded credentials, ignored errors in critical paths, known vulnerabilities |
| HIGH | Missing error context (return err without wrapping), panic instead of error return, context not propagated, unbuffered channels risking deadlock |
| MEDIUM | Non-idiomatic patterns, missing godoc on exports, inefficient string concatenation, slice not preallocated |
Step 4: Output report
GO REVIEW REPORT
================
go vet: [PASS/X issues]
staticcheck: [PASS/X issues]
golangci-lint: [PASS/X issues]
race check: [PASS/FAIL]
govulncheck: [PASS/X vulns]
CRITICAL: X | HIGH: X | MEDIUM: X
[List each issue with file:line, description, and fix suggestion]
Verdict: [APPROVE / BLOCK]
- APPROVE: No CRITICAL or HIGH issues
- BLOCK: Has CRITICAL or HIGH issues
Step 5: Offer fixes
For CRITICAL and HIGH issues, provide concrete code fixes. For MEDIUM issues, list them but don't block.