NilAway is a static analysis tool that detects potential nil panics in Go code at compile time.
NilAway addresses the problem of nil pointer dereferences causing runtime panics by analyzing code flow to identify where nil values might be dereferenced. Unlike the standard nilness analyzer in the Go toolchain, it employs more sophisticated static analysis techniques to track nil flows both within and across packages. The tool uses an inference engine to automatically detect these issues without requiring developers to add annotations or other metadata to their code.
Developers should adopt NilAway if they want to catch nil panics before production while maintaining reasonable build-time performance. The tool is designed to be practical rather than exhaustive, catching most nil panics observed in production while keeping analysis overhead low. It integrates with standard Go analysis drivers including golangci-lint, nogo, and can run as a standalone checker. For large projects with many dependencies, the tool recommends using the include-pkgs flag to analyze only first-party code, which significantly improves performance by skipping dependency analysis. The README notes that modular analysis drivers like bazel/nogo or golangci-lint are preferred over the standalone checker for large projects due to the tool's use of the Fact Mechanism for caching analysis results.
The project is under active development with a stated expectation that false positives and breaking changes may occur. Development activity shows ongoing optimization work to reduce build-time overhead, with measurements indicating less than five percent overhead in typical use. The maintainers are actively soliciting feedback and contributions from users.