go-defensive
CommunityDefensive Go patterns for robust, clean code.
Authorcxuu
Version1.0.0
Installs0
System Documentation
What problem does it solve?
Go defensive programming patterns help engineers write robust, maintainable Go by enforcing safety boundaries and reducing common runtime errors.
Core Features & Use Cases
- Interface verification: compile-time checks to ensure types satisfy interfaces.
- Safe data ownership: copy slices and maps when crossing API boundaries to avoid unintended mutations.
- Deferral discipline: use defer to ensure resources are released correctly and safely.
- Avoid mutable globals: inject dependencies to keep code testable and predictable.
- Explicit field tagging: use struct field tags for stable serialization contracts.
- Time handling: prefer time.Time and time.Duration to avoid ambiguous raw integers.
Quick Start
Refactor code to enforce interface checks, copy-on-boundary data, and proper defer cleanup for all critical packages.
Dependency Matrix
Required Modules
None requiredComponents
references
💻 Claude Code Installation
Recommended: Let Claude install automatically. Simply copy and paste the text below to Claude Code.
Please help me install this Skill: Name: go-defensive Download link: https://github.com/cxuu/golang-skills/archive/main.zip#go-defensive Please download this .zip file, extract it, and install it in the .claude/skills/ directory.
Agent Skills Search Helper
Install a tiny helper to your Agent, search and equip skill from 223,000+ vetted skills library on demand.