
Go Defensive
This one covers the defensive patterns that aren't about error handling: copying slices and maps at API boundaries to prevent mutation bugs, using defer for cleanup, compile-time interface checks, and the small things like starting iota enums at 1 so zero means uninitialized. The checklist ordering is smart. It walks through API boundary hardening top to bottom, and the separation between crypto/rand for keys versus math/rand for non-security randomness is the kind of thing that causes real vulnerabilities when people get it wrong. The panic and recover guidance is stricter than most Go tutorials, insisting libraries never expose panics across package boundaries. Good complement to go-error-handling if you want the full defensive posture without overlap.
- skills.sh installs
- 1.3K
- GitHub stars
- 193
- last updated
- Aug 21, 2026
Install
$ npx -y skills add cxuu/golang-skills --skill go-defensive --agent claude-codeInstalls into .claude/skills of the current project.
Files
Go Defensive Programming Patterns
Compatibility: Crypto examples may use
crypto/rand.Text, which requires Go 1.24+.
Resource Routing
references/BOUNDARY-COPYING.md- Read when copying slices/maps across API boundaries.references/GLOBAL-STATE.md- Read when introducing or removing package globals.references/MUST-FUNCTIONS.md- Read when deciding whether a panic-on-error helper is acceptable.references/PANIC-RECOVER.md- Read when evaluating panic, recover, or crash containment.references/TIME-ENUMS-TAGS.md- Read when handling time types, enum zero values, or struct tags.
Defensive Checklist Priority
When hardening code at API boundaries, check in this order:
Sponsors
Details
- Repository
- github.com/cxuu/golang-skills
- Categories
- Backend & APIs, Security, Debugging, Rust, Go, Finance & Trading
- First seen
- May 16, 2026
More from cxuu/golang-skills
All 20- Go Packages1.3K
- Go Data Structures1.3K
- Go Functional Options1.3K
- Go Control Flow1.3K
- Go Logging1.1K
- Go Functions1.1K
- Go Generics1.1K
- Go Declarations1.1K
- Go Code Review1.8K
- Go Testing1.4K
- Go Error Handling1.3K
- Go Linting1.3K
- Go Concurrency1.3K
- Go Interfaces1.3K
- Go Documentation1.3K
- Go Style Core1.3K
- Go Performance1.3K
- Go Context1.3K
- Go Naming1.3K