Skip to content
A hawk sheltering the Go gopher

gohawk

Watch for bugs like a hawk!

gohawk is a correctness-oriented suite of Go analyzers. It uses SSA-backed static analysis to catch bugs based on deep understanding of a program's control flow and resource lifecycles.

Get started

1package worker
2
3func run(jobs []Job) {
4    var err error
5    for _, job := range jobs {
6        go func() {
7            prepare(job)
8            err = fetch()
9        }()
10    }
11}
$ go install github.com/kojah/gohawk@latest
$ gohawk ./...
warning[concurrentcapture]: captured local err is mutated by goroutines launched repeatedly
  --> worker.go:8:4
  |
8 |      err = fetch()
  |      ^~~

Better together

gohawk complements your existing analyzers such as go vet, Staticcheck, and go-critic; it does not try to replace them.

Easy to drop in

gohawk runs as a standalone tool or as a go vet tool. No configuration file, and every check is a command-line flag.

Analysis features

gohawk analyzers are primarily focused on enforcing reliability around resource management, concurrency, and error handling.

Rich diagnostics

Each finding pinpoints the offending code with a precise source span and includes a suggested fix when gohawk can provide one safely.