go-nil-interface
Installation
SKILL.md
Interface Nil Trap
Problem
A typed nil pointer stored in an interface is NOT nil.
Pattern
WRONG - Typed nil escapes
func GetUser(id int) error {
var err *MyError // typed nil
if id < 0 {
err = &MyError{"invalid id"}
}
return err // Returns non-nil interface containing nil pointer!
}