cxuu avatar

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-code

Installs 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
1neolabhq avatarsetup-serena-mcpneolabhq/context-engineering-kitGuide for setup Serena MCP server for semantic code retrieval and editing capabilities1.3Kskills.sh installs
2fluxcd avatargitops-knowledgefluxcd/agent-skillsFlux CD and Flux Operator expert — answers questions and generates schema-validated YAML for all Flux CRDs (not repo auditing or live cluster debugging). Use wh1.3Kskills.sh installs
3langchain-ai avatarquery-writinglangchain-ai/deepagentsWrites and executes SQL queries from simple SELECTs to complex multi-table JOINs, aggregations, and subqueries. Use when the user asks to query a database, writ1.3Kskills.sh installs
4langchain-ai avatarschema-explorationlangchain-ai/deepagentsLists tables, describes columns and data types, identifies foreign key relationships, and maps entity relationships in a database. Use when the user asks about 1.3Kskills.sh installs
5nvidia avatarcuopt-routing-formulationnvidia/skillsVehicle routing (VRP, TSP, PDP) — problem types and data requirements. Domain concepts; no API or interface.1.3Kskills.sh installs
6nvidia avatarnemoclaw-user-guidenvidia/skillsGuides human users' AI agents to the NemoClaw docs MCP server and canonical Fern documentation in Markdown form. Use when users ask how to install, configure, o1.3Kskills.sh installs