smithery/JamesPrial

go-nil-slice

Slice zero-value behavior - nil slice is usable

Installation

$ npx skills add smithery/JamesPrial --skill go-nil-slice

Similar popular skills

Related neighbors and high-traction skills in the same topics — useful to compare before installing.

Also in this package

Other skills from smithery/JamesPrial · top by installs.

npx skills add smithery/JamesPrial

Browse all from smithery/JamesPrial

More details

Agent compatibility

Declared targets from SKILL.md / docs. Unmarked agents are not listed — the skill may still install via the CLI.

Claude Code Not declared
Cursor Not declared
Codex Not declared
GitHub Copilot Not declared
Windsurf Not declared
Gemini CLI Not declared
Cline Not declared
OpenCode Not declared

Package contents

Files included with this skill beyond the listing page.

  • skill md SKILL.md 1,026 B
  • docs SUMMARY.md 67 B

History

  1. First recorded snapshot · 0 installs

SKILL.md

Slice Zero-Value

Problem

Nil slices are valid and usable, but behavior differs from empty slices.

Pattern

CORRECT - Nil slice works with append

var s []int  // nil slice
s = append(s, 1, 2, 3)  // OK, creates new backing array
fmt.Println(s)  // [1 2 3]

Nil vs Empty Slice

var nilSlice []int           // nil slice
emptySlice := []int{}        // empty slice (non-nil)

len(nilSlice) == 0           // true
len(emptySlice) == 0         // true

nilSlice == nil              // true
emptySlice == nil            // false

json.Marshal(nilSlice)       // "null"
json.Marshal(emptySlice)     // "[]"

When It Matters

// JSON encoding differs
type Response struct {
    Items []string  // Will encode as null if nil, [] if empty
}

Quick Fix

  • Nil slices work with append, len, range
  • Use nil for "no data", []T{} for "empty data"
  • Check JSON encoding behavior if needed