z-go-safety

Installation
SKILL.md

Go Safety

Quick Reference

Risk Fix
Typed nil in interface Return untyped nil, never a typed nil pointer
Nil map write make or lazy-init in the method
append aliasing Cap-limit before growing; clone for independent elements; both are shallow
Bare type assertion Always comma-ok: v, ok := x.(T)
defer in loop Extract body to a function
Integer narrowing Bounds-check against math.MaxInt32 first
Float comparison choose domain-specific absolute/relative tolerances; handle NaN/infinity explicitly
Iota enum Plain iota from 0 with a real state at zero (default); iota + 1 only if zero-as-invalid genuinely matters
Mutable global Inject func() time.Time
Crypto keys rand.Read() + hex.EncodeToString (or rand.Int(rand.Reader, ...)); rand.Text() (Go 1.24+) is a shorthand alt

Installs
15
First Seen
Jul 2, 2026