con un clic
go-nil-pointer
Pointer receiver nil safety - methods can be called on nil
Instalar con Codex o Claude Copia este prompt, pégalo en Codex, Claude u otro asistente, y deja que revise la página de la skill y la instale por ti.
Menú
Pointer receiver nil safety - methods can be called on nil
Instalar con Codex o Claude Copia este prompt, pégalo en Codex, Claude u otro asistente, y deja que revise la página de la skill y la instale por ti.
Basado en la clasificación ocupacional SOC
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.