cxuu avatar

Go Defensive

Hardening patterns for Go API boundaries covering copies, defer cleanup, crypto rand, and robustness review.

skills.sh installs
1.3K
GitHub stars
196
last updated
Aug 21, 2026
View on GitHub

Own this skill? Claim it

What it does

  • Covers boundary copying of slices and maps, defer-based cleanup, enum zero values, and avoiding mutable package globals
  • Includes reference guides for boundary copying, global state, Must functions, panic and recover, and time, enum, and tag rules
  • Enforces crypto/rand for key generation over math/rand, and flags missing cleanup or unsafe crypto during reviews
  • Designed for reviewing Go API code for robustness; error handling strategy is delegated to go-error-handling and interface checks to go-interfaces

Install

$ npx -y skills add cxuu/golang-skills --skill go-defensive -y

Installs into .agents/skills for every agent it finds here, and .claude/skills for Claude Code.

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:

Details

Repository
github.com/cxuu/golang-skills
Categories
Go, Security
First seen
May 16, 2026

More from cxuu/golang-skills

All 20

Similar to Go Defensive

More Go