What problem does it solve?
This Skill helps you make Go code safer at package and API boundaries by preventing hidden mutation, unclear time handling, accidental panics, and weak randomness. It reduces bugs that appear when callers can modify your internal state or when code is hard to test and reason about.
Core Features & Use Cases
- Boundary copying: Copy slices and maps on input or output when ownership should not be shared.
- Cleanup discipline: Place defer right after acquire for files, locks, and other resources.
- Robust modeling: Use time.Time, time.Duration, injected clocks, and invalid zero-value enums for clearer APIs.
- Safety checks: Verify interface compliance at compile time, avoid mutable globals, and use crypto-rand for secrets.
- Use case: Review an exported Go service method and harden it so callers cannot mutate internal state, tests can control time, and errors are returned safely instead of panicking.
Quick Start
Apply the go-defensive skill to this Go package and review its exported APIs for boundary copying, cleanup placement, time modeling, enum safety, and panic-free error handling.