kit-go-review
Review Go code for language-level defects, including goroutine leaks, data races, unchecked or shadowed errors, context misuse, nil map writes, defer in loops, and unsafe concurrency patterns, and rep
SKILL.mdregistry/skills/go-review/SKILL.md
GitHubGo review
Report findings without modifying code unless the user asks for fixes. Read project instructions and go.mod for the Go version first; loop variable semantics changed in Go 1.22.
1. Determine the scope
Review the files, package, or diff the user named; otherwise the uncommitted changes and the current branch against its base. Read callers and tests for enough context.
2. Check
Errors
- Ignored errors (
_ =or unchecked returns fromClose,Write,json.Unmarshal),errshadowed with:=in an inner scope so the outer check seesnil, and errors compared with==instead oferrors.Isafter wrapping. panicused for ordinary errors in library code;log.Fataloutsidemain.
Concurrency
- Goroutines with no exit path: blocked sends on unbuffered channels nobody reads, missing
ctx.Done()in loops. Channels closed by a receiver or closed twice. - Data races: maps or slices written from several goroutines without a mutex,
sync.WaitGroup.Addcalled inside the goroutine, copying structs that contain async.Mutex. Suggestgo test -raceto confirm. - Before Go 1.22, closures in loops capturing the loop variable.
Context and resources
- Before Go 1.23,
time.Afterin long loops keeps each timer alive until it fires; usetime.NewTimerwithStoporReset. context.Background()used where a request context exists,cancelfromWithTimeoutnot deferred, contexts stored in structs.deferinside a loop holding files or locks until the function returns; HTTP response bodies not closed;http.Clientwithout a timeout.
Correctness
- Writes to a nil map, nil pointer dereferences after an error path, slices aliased through
appendon a shared backing array, integer conversion overflow, andtime.Timecompared with==. - Interfaces holding a typed nil pointer compared with
nil.
3. Verify and report
Confirm findings by tracing the code; run go vet ./..., go build ./..., and go test -race ./... when available. Report findings ordered by severity (critical, high, medium, low) with file:line, the problem, a concrete triggering scenario, and a fix. If there are no findings, say so and list what was checked.
Examples
- Use: "Review internal/worker for concurrency bugs." "Check my Go changes for goroutine leaks."
- Skip: "Review the SQL in store.go." (kit-go-sql-review) "Add a /health endpoint." (kit-go-http-api)