# Go defensive coding

> Hardens Go code against typed nils, slice aliasing and overflow, so it stops panicking or corrupting data.

- Page: https://youraiskill.com/skill/eduardo-sl-go-defensive-coding
- What it does: Prevent panics, silent corruption, and subtle runtime bugs in Go: typed-nil interfaces, slice aliasing, integer overflow on conversion, float comparison, defer in loops, defensive copying at API boundaries, and zero-value design. Use when hardening code against crashes, reviewing for nil-safety, converting between numeric types, or deciding what to copy at a package boundary. Trigger examples: "nil pointer panic", "why is my error not nil", "slice aliasing", "integer overflow", "compare floats", "defer in a loop", "defensive copy", "make this crash-proof". Not for: data races and goroutine lifecycle (go-concurrency-review), injection and auth (go-security-audit), a panic that already happened (go-troubleshooting).
- Niches: coding, security
- Licence: MIT
- Status: Checked: open licence, author credited, passed the YourAISkill safety scan. Can be added to a paid pack.
- Contents: instructions and reference files only (4 files)

To add it, see https://youraiskill.com/guides/how-to-add-a-skill-to-claude
