How dominikh/go-tools works
Staticcheck is a Go static-analysis suite: its main workflow loads packages, runs registered checks, and presents diagnostics, with cache-backed execution. Its checks include bug/performance diagnostics, simplifications, style rules, and unused-code analysis. The README also documents separate struct-layout tools. The graph preserves those product branches and the IR/dataflow analysis layer; some subsystem links rely on README descriptions or indexed references rather than complete source excerpts.
Main entry points: lint.go Analysis API · runner.go Analysis runner · cmd.go Lint frontend · staticcheck.go Staticcheck CLI
Components 21
CLI and execution
- Staticcheck CLI
cmd/staticcheck/staticcheck.go - Lint frontend
lintcmd/cmd.go - Analysis runner
lintcmd/runner/runner.go - Result cache
lintcmd/cache/cache.go - Diagnostics output
lintcmd/format.go
Analysis checks
- Staticcheck registry
staticcheck/analysis.go - Bug checks
staticcheck/sa1019/sa1019.go - Simplification checks
simple/analysis.go - Style checks
stylecheck/analysis.go - Quick fixes
quickfix/analysis.go - Unused-code analysis
unused/unused.go
Analysis engine
- Analysis API
analysis/lint/lint.go - Code inspection
analysis/code/code.go - Report helpers
analysis/report/report.go - Package loader
go/loader/loader.go - SSA IR builder
go/ir/builder.go - Nilness analysis
analysis/facts/nilness/nilness.go
Go utilities
- Struct layout
cmd/structlayout/main.go - Layout optimizer
cmd/structlayout-optimize/main.go - Layout formatter
cmd/structlayout-pretty/main.go
Other components
- Go developer
Connections 17
- Go developer → Staticcheck CLI: runs
- Staticcheck CLI → Lint frontend: starts
- Lint frontend → Analysis runner: runs checks
lintcmd/cmd.go - Analysis runner → Package loader: loads packages
lintcmd/runner/runner.go - Analysis runner → Result cache: caches results
lintcmd/runner/runner.go - Analysis runner → Staticcheck registry: runs analyzers
- Staticcheck registry → Bug checks: registers
staticcheck/analysis.go - Lint frontend → Diagnostics output: formats findings
- Bug checks → Analysis API: implements checks
staticcheck/sa1019/sa1019.go - Simplification checks → Analysis API: implements checks
- Style checks → Analysis API: implements checks
- Quick fixes → Analysis API: implements checks
- Unused-code analysis → Analysis API: uses analysis API
unused/unused.go - Nilness analysis → SSA IR builder: analyzes IR
analysis/facts/nilness/nilness.go - Struct layout → Go developer: shows layout
- Layout optimizer → Go developer: reorders fields
- Layout formatter → Go developer: formats layout