What problem does it solve?
Go programs frequently suffer from panics and subtle runtime bugs due to nil interfaces, nil maps/slices, improper delegation, and unsafe type conversions. This Skill provides defensive patterns and checklists to prevent crashes and data corruption.
Core Features & Use Cases
- Nil safety patterns: guards for nil receivers, typed nil interfaces, and nil function values.
- Defensive copying: return safe copies of slices and maps to protect internal state.
- Resource lifecycle safety: avoid defer-in-loops and ensure resources are released per iteration.
- Initialization best practices: lazy and constructor-based initialization to prevent nil map panics.
- Deterministic behavior: avoiding unintended aliasing and non-deterministic map iteration orders.
Quick Start
Apply these patterns by auditing representative Go code paths for nil interfaces, maps, and slices, refactoring to use defensive copies and proper initialization.