go-nil

Go nil safety patterns. Routes to specific traps.

⭐2stars🔀0forks📁View on GitHub🕐Updated Dec 28, 2025

When & Why to Use This Skill

This Claude skill provides a comprehensive guide and pattern library for Go nil safety, specifically designed to help developers identify and avoid common runtime panics. It offers structured solutions for the most frequent 'nil traps' in Golang, including interface comparisons, map writes, and pointer dereferences, ensuring more robust and stable codebases.

Use Cases

  • Identifying and fixing the 'typed nil != nil interface' logic error that causes unexpected behavior in conditional statements.
  • Preventing runtime panics by implementing safe patterns for writing to maps and handling zero-value slices.
  • Debugging 'nil pointer dereference' issues by applying best practices for pointer receivers and pre-dereference checks.
  • Reviewing Go source code to detect uninitialized variables that could lead to system crashes in production.
namego-nil
descriptionGo nil safety patterns. Routes to specific traps.

Nil Safety

Route by Type

Quick Check

  • Check pointers before deref
  • Check maps before write
  • Typed nil != nil interface

Common Gotcha

var p *int
if p == nil {  // true
    fmt.Println("nil pointer")
}