npx claudepluginhub jamesprial/prial-plugins --plugin golang-workflowThis skill uses the workspace's default tool permissions.
A typed nil pointer stored in an interface is NOT nil.
Enforces defensive Go coding to prevent nil panics, append aliasing, map/channel access bugs, defer pitfalls, numeric issues, and data corruption in Go code.
Guides Go interface usage: defining/implementing, abstractions, mockable testing boundaries, embedding, accepting interfaces vs concrete returns, type assertions/switches. Includes compliance check script.
Provides Go error handling patterns: wrapping with %w, sentinel errors, custom types, errors.Is/As. Use for implementing, designing error types, debugging chains, reviewing code.
Share bugs, ideas, or general feedback.
A typed nil pointer stored in an interface is NOT nil.
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!
}
if err := GetUser(1); err != nil {
// This branch RUNS even though no error occurred
fmt.Println("error:", err)
}
func GetUser(id int) error {
if id < 0 {
return &MyError{"invalid id"}
}
return nil // Return untyped nil
}
if err := GetUser(1); err != nil {
// This branch does NOT run
fmt.Println("error:", err)
}
Interface contains (type, value). Typed nil has (type=*MyError, value=nil). This is different from (type=nil, value=nil).