Use when hardening Go code at API boundaries — copying slices/maps, verifying interface compliance, using defer for cleanup, time.Time/time.Duration, or…
Go Defensive Programming Patterns Defensive Checklist Priority When hardening code at API boundaries, check in this order: Reviewing an API boundary? ├─ 1. Error handling → Return errors; don't panic (see go-error-handling) ├─ 2. Input validation → Copy slices/maps received from callers ├─ 3. Output safety → Copy slices/maps before returning to callers ├─ 4. Resource cleanup → Use defer for Close/Unlock/Cancel ├─ 5. Interface checks → var _ Interface = (*Type)(nil) for compile-time verification ├─ 6. Time correctness → Use time.Time and time.Duration, not int/float ├─ 7. Enum safety → Start iota at 1 so zero-value is invalid └─ 8. Crypto safety → crypto/rand for keys, never math/rand
don't have the plugin yet? install it then click "run inline in claude" again.