Skip to content
Skill

Go data structures

Guides Go code on slices, maps, sets and arrays to avoid aliasing and nil bugs

Go data structures is an open-source agent skill for developer tools. It is available on Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, Windsurf and Goose.

Scripts
None
Platforms
Claude Code, Codex, Cursor
GitHub stars
90
Last commit
License
MIT
Listing updated

Similar skills

About Go data structures

This skill gives the agent a set of rules for using Go's built-in collection types correctly. It covers the difference between nil and empty slices, when append can write into a shared backing array, how to copy or preallocate slices and maps, comma-ok lookups, writes to nil maps, and deterministic map iteration. It also includes guidance on choosing between slices, maps, sets and arrays, and on picking containers such as container/heap, container/list, sync.Map or a mutex-guarded map for specific jobs.

The agent works through a verification checklist covering nil handling, subslice retention, capacity, map shrinking and popping pointers from slices. A reference file, loaded on demand, adds examples for priority queues, LRU caches and weak-pointer caches. The skill asks the agent to read and edit Go files, run go and gofmt, and search the codebase.

It expects a Go project with the Go toolchain installed. Some advice depends on newer Go versions, such as slices.Sorted and maps.Keys from Go 1.23 and weak.Pointer from Go 1.24.

When your agent uses it

Correct use of Go's built-in data structures: slices (nil vs empty, append semantics, aliasing, preallocation), maps (comma-ok, sets, iteration order), arrays, and choosing between them. Use when: "slice vs array", "nil slice", "empty slice", "preallocate", "map iteration", "use a set in Go", "slice aliasing", "append gotcha", "copy a slice", "sync.Map or mutex". Not for: structures shared across goroutines (go-concurrency-review), allocation profiling (go-performance-review), generic containers (go-design-patterns).

From the skill's SKILL.md. Your agent reads this description to decide when to load the skill.

What it can access

From a static check of its 2 files (11 KB) on GitHub on 3 December 2026. Nothing was run. Read the files before you install a skill: it can tell your agent to run anything its tools allow.

Check another skill before you install it.

Install

Download the skill folder from https://github.com/eduardo-sl/go-agent-skills and copy it into your agent's skills folder.

What it does

Nil vs empty slices
Explains when a nil slice is preferable and where JSON output requires an empty slice.
Append and aliasing rules
Shows when append can write into a caller's backing array and how to force a copy.
Preallocation guidance
Recommends allocating slices and maps with known capacity and avoiding it when size is unknown.
Map safety and iteration
Covers comma-ok lookups, nil map writes and sorting keys for deterministic output.
Set and container selection
Provides a table mapping common needs to map, slice, heap, list or sync.Map choices.
Memory and copy behaviour
Describes map shrinkage, slice clearing, pointer slot cleanup and shallow clone effects.

Good for

  • Review my Go code for slice aliasing bugs caused by append
  • Remove duplicates from this list using a set in Go
  • Make this function return an empty JSON array instead of null
  • Preallocate the slices and maps in this Go loop
  • Fix the panic from writing to a nil map
  • Pick between sync.Map and a mutex-guarded map for this cache

Go data structures FAQ

What does Go data structures need to run?

It requires the Go toolchain and is designed for Claude Code or similar AI coding agents working on Go projects.

Does Go data structures run scripts or change files on its own?

It has no scripts. It lists allowed tools for reading, editing and writing files, searching, and running go and gofmt commands.

When should I not use Go data structures?

The skill says not to use it for structures shared across goroutines, allocation profiling, or generic containers. Those are handled by other skills named in its description.

Are there extra reference materials?

Yes. A reference file covers container/heap priority queues, LRU caches with container/list, reclaiming map memory, and a weak.Pointer cache, and is read only when needed.

Does Go data structures run scripts?

No. It is instructions only, with no scripts. This comes from a static check of the files on GitHub; nothing was run. Read the files before you install it.

Which AI agents can use Go data structures?

Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, Windsurf and Goose. Each reads skills in the SKILL.md format from its own folder; the install steps on this page list them.

What are the best alternatives to Go data structures?

The closest alternatives to Go data structures are Go defensive coding, Go interface design, Go coding standards, Go performance review and Go design patterns.

Where this comes from

  • Description: from the skill's own SKILL.md.

More from eduardo-sl/go-agent-skills

  1. Guides Go agents in designing HTTP REST APIs, handlers, middleware and shutdown

    • Open source
    • 90 GitHub stars
    • Developer tools
  2. Reviews Go project structure, dependency direction and module boundaries

    • Open source
    • 90 GitHub stars
    • Developer tools
  3. Guides an AI agent to build Go command-line tools with clean flags, streams and exit codes

    • Open source
    • 90 GitHub stars
    • Developer tools
  4. Guides Go code toward constructor injection, explicit wiring and no global state

    • Open source
    • 90 GitHub stars
    • Developer tools
  5. Guides Go code toward idiomatic design patterns like functional options and factories

    • Open source
    • 90 GitHub stars
    • Developer tools
  6. Guides building Go GraphQL servers with gqlgen, covering N+1 batching and query limits

    • Open source
    • 90 GitHub stars
    • Developer tools