Agent skill
go-nil-map
Map nil safety - read OK, write panics
Install this agent skill to your Project
npx add-skill https://github.com/majiayu000/claude-skill-registry/tree/main/skills/development/go-nil-map
SKILL.md
Map Nil Safety
Problem
Reading from nil map returns zero value. Writing to nil map panics.
Pattern
WRONG - Write to nil map
var m map[string]int // nil map
m["key"] = 42 // PANIC: assignment to entry in nil map
CORRECT - Initialize with make
m := make(map[string]int)
m["key"] = 42 // OK
Reading is Safe
var m map[string]int // nil map
v := m["key"] // OK, v = 0 (zero value)
v, ok := m["key"] // OK, v = 0, ok = false
Quick Fix
- Always initialize maps with make() before writing
- Check if map is nil before range/write
- Reading from nil map is safe but returns zero values
Defensive Pattern
if m == nil {
m = make(map[string]int)
}
m["key"] = 42
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
Didn't find tool you were looking for?