---
title: "NilAway: Practical Nil Panic Detection for Go"
description: "NilAway is Uber’s static analyzer for detecting potential nil pointer dereferences in Go before they reach production, where nil panics have caused incorrect behavior, outages, and denial-of-service risks. It models nilability flows as global typing constraints over struct fields, function parameters, and return values, builds an implication graph, and uses 2-SAT-style reasoning with forward nilness and backward nonnil propagation to identify contradictions. The analysis is interprocedural, requires no developer annotations, and reports detailed flows, while acknowledging false positives when runtime invariants are not captured. In one Uber service logging more than 3,000 nil panics daily, NilAway identified a receive-from-closed-channel path; adding a nilness check reduced the reported panics to zero, and the tool was released as open source with comprehensive and changed-code onboarding options."
---

# NilAway: Practical Nil Panic Detection for Go

[Uber](https://yomu.fyi/company/uber) · Jun 23, 2026

**Type:** Problem & solution

## Summary

NilAway is Uber’s static analyzer for detecting potential nil pointer dereferences in Go before they reach production, where nil panics have caused incorrect behavior, outages, and denial-of-service risks. It models nilability flows as global typing constraints over struct fields, function parameters, and return values, builds an implication graph, and uses 2-SAT-style reasoning with forward nilness and backward nonnil propagation to identify contradictions. The analysis is interprocedural, requires no developer annotations, and reports detailed flows, while acknowledging false positives when runtime invariants are not captured. In one Uber service logging more than 3,000 nil panics daily, NilAway identified a receive-from-closed-channel path; adding a nilness check reduced the reported panics to zero, and the tool was released as open source with comprehensive and changed-code onboarding options.

## Context

Uber’s 90-million-line Go monorepo had experienced production runtime errors from nil panics, including incorrect behavior and app outages. Existing nilness analysis detected only simple dereferences, while adapting Java’s annotation-based NullAway approach was impractical because Go lacks annotation support and annotating the monorepo would be cumbersome.

## Approach / What changed

NilAway uses interprocedural static analysis and inference to model nilability as global typing constraints. It captures nilable and nonnil constraints for struct fields, parameters, and return values, builds an implication graph, and uses 2-SAT-style propagation to report unsafe nil flows. It supports comprehensive enforcement or non-blocking changed-code checks, without requiring annotations.

## Takeaways

- NilAway identifies contradictions where a witnessed nil value flows to a site requiring a nonnil value, then reports the detailed path from the nil source to the dereference.
- The analysis can produce false positives when subtle interprocedural execution invariants prevent a nil flow at runtime, although the source reports a low false-positive rate in practice.
- In a service logging more than 3,000 nil panics per day, NilAway found a receive-from-closed-channel path; adding a nilness check reduced the reported panics to zero.

**Tags:** [Go](https://yomu.fyi/topic/go), [Open Source](https://yomu.fyi/topic/open-source), [Static Typing](https://yomu.fyi/topic/static-typing)

- Source: [Uber](https://www.uber.com/us/en/blog/nilaway-practical-nil-panic-detection-for-go)
- Source URL: https://www.uber.com/us/en/blog/nilaway-practical-nil-panic-detection-for-go
- Ingested by Yomu: 2026-09-11T16:02:05.219Z

[Read original post](https://www.uber.com/us/en/blog/nilaway-practical-nil-panic-detection-for-go)
