How ktaffy/gophercheck works
Gophercheck is a Go static performance-analysis CLI. Its main workflow loads configuration, collects Go files, parses and analyzes them with enabled detectors, then formats issues and a performance score for console/JSON or a file. Watch mode is a second entry path: filesystem events are filtered and debounced before the CLI reruns analysis. README capabilities are retained at detector level; the excerpts do not expose every detector’s internals or all analysis/report wiring.
Main entry points: ast_walker.go Analyzer engine · root.go CLI commands · file_watcher.go File watcher · main.go Program entry
Components 21
CLI workflow
- Program entry
main.go - CLI commands
cmd/root.go - Configuration
internal/config/config.go - Go file collection
cmd/root.go
Static analysis
- Analyzer engine
internal/analyzer/ast_walker.go - Analysis context
internal/context/analysis_context.go - Complexity checks
internal/analyzer/detectors/complexity.go - Function length
internal/analyzer/detectors/function_length.go - Nested-loop checks
internal/analyzer/detectors/nested_loops.go - String concatenation
internal/analyzer/detectors/string_concat.go - Memory allocation
internal/analyzer/detectors/memory_alloc.go - Slice growth
internal/analyzer/detectors/slice_growth.go - Data structures
internal/analyzer/detectors/data_structure.go - Import cycles
internal/analyzer/detectors/import_cycle.go
Issues and reports
- Issue results
internal/models/issue.go - Report generator
internal/analyzer/report.go
Watch mode
- File watcher
internal/watcher/file_watcher.go - Event debouncer
internal/watcher/debouncer.go
Other components
- CLI user
- Report destination
- Watched filesystem
Connections 23
- CLI user → Program entry: invokes
- Program entry → CLI commands: dispatches
- CLI commands → Configuration: loads
- CLI commands → Go file collection: collects
- CLI commands → Analyzer engine: runs analysis
- CLI commands → Report generator: generates report
- Go file collection → Analyzer engine: provides files
- Analyzer engine → Analysis context: uses context
- Analyzer engine → Complexity checks: dispatches
- Analyzer engine → Function length: dispatches
- Analyzer engine → Nested-loop checks: dispatches
- Analyzer engine → String concatenation: dispatches
- Analyzer engine → Memory allocation: dispatches
- Analyzer engine → Slice growth: dispatches
- Analyzer engine → Data structures: dispatches
- Analyzer engine → Import cycles: dispatches
- Analyzer engine → Issue results: accumulates
- Report generator → Issue results: reads
- CLI commands → Report destination: writes report
- CLI commands → File watcher: starts watch
- Watched filesystem → File watcher: emits changes
- File watcher → Event debouncer: queues events
- Event debouncer → CLI commands: calls change handler