with one click
go-nil-pointer
Pointer receiver nil safety - methods can be called on nil
Install with Codex or Claude Copy this prompt, paste it into Codex, Claude, or another assistant, and let it review the skill page and install it for you.
Menu
Pointer receiver nil safety - methods can be called on nil
Install with Codex or Claude Copy this prompt, paste it into Codex, Claude, or another assistant, and let it review the skill page and install it for you.
Based on SOC occupation classification
Handle hook scripts and paths for plugin packaging
Package claudefiles components into a valid Claude Code plugin
Package language-specific subsets of claudefiles
Plugin validation errors and fixes
Common channel patterns and idioms
Context cancellation patterns for graceful shutdown
| name | go-nil-pointer |
| description | Pointer receiver nil safety - methods can be called on nil |
Methods with pointer receivers can be called on nil. Must handle nil receiver.
type Tree struct {
Value int
Left *Tree
}
func (t *Tree) Sum() int {
return t.Value + t.Left.Sum() // PANIC if t or t.Left is nil
}
type Tree struct {
Value int
Left *Tree
Right *Tree
}
func (t *Tree) Sum() int {
if t == nil {
return 0 // Nil tree has sum of 0
}
return t.Value + t.Left.Sum() + t.Right.Sum()
}
// Now safe to call
var tree *Tree // nil
sum := tree.Sum() // Returns 0, no panic
Nil receiver pattern enables elegant recursive algorithms and optional behavior.
If nil receiver doesn't make semantic sense, panic early with clear message.