golang-data-structures

Select and implement efficient Go data structures for performance-critical coding tasks.

1|Updated May 27, 2026
One-click install
npx skills add https://github.com/dmwin72015/netdisk --skill golang-data-structures-dmwin72015
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: golang-data-structures
Source: https://github.com/dmwin72015/netdisk/tree/main/.agents/skills/golang-data-structures
Command: npx skills add https://github.com/dmwin72015/netdisk --skill golang-data-structures-dmwin72015

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill helps you choose and implement the most appropriate Go data structures by explaining how slices, maps, arrays, standard containers, and pointers actually behave in memory and under the hood.

Core Features & Use Cases

  • Slice & map internals for performance: Understand capacity growth, preallocation, backing-array aliasing, hash buckets, and why map memory behavior can surprise you in production.
  • Correct standard-library container usage: Use container/list, container/heap, and container/ring when their complexity and memory characteristics fit the problem.
  • Safety-focused guidance: Avoid nil-map/slice pitfalls, append aliasing traps, defensive copy mistakes, and unsafe/weak pointer misuse.
  • Use Case: When building an upload task queue or caching layer in a Go service, use this Skill to decide between slices vs maps vs containers, then apply preallocation, the right builder/buffer choice, and safe pointer semantics to reduce allocations and bugs.

Quick Start

Use the golang-data-structures skill to design and optimize the internal data representation for your Go component handling large volumes of requests.

Frequently Asked Questions about golang-data-structures

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I prevent Go slice append aliasing when sharing backing arrays?

Avoid Go slice append aliasing by preallocating slices with sufficient capacity and applying defensive copies before sharing backing arrays, preventing unexpected data mutations across concurrent operations.

What is the best way to preallocate Go maps and slices for high-performance caching?

Preallocate Go maps and slices by specifying initial capacity hints at creation, minimizing hash bucket resizing, backing array reallocation, and garbage collection overhead in high-performance caching layers.

When should I use container/heap versus standard slices for priority queues in Go?

Use container/heap for priority queues in Go when you need dynamic ordering with efficient insertions and extractions, whereas standard slices fit simpler fixed-size or linear iteration scheduling tasks.

Why does my Go map memory usage stay high after deleting keys?

Go map memory usage remains high after deleting keys because underlying hash bucket arrays do not shrink dynamically, requiring a complete map rebuild or reassignment to release allocated memory.

How do unsafe and weak pointers work in Go for deduplication and interning?

Unsafe and weak pointers in Go enable deduplication and interning by allowing manual memory management and non-owning references, letting caches track values without preventing garbage collection of unreferenced entries.

Can I use container/list and container/ring for upload task queues in Go services?

Use container/list for doubly-linked upload task queues in Go services requiring frequent insertions and deletions, while container/ring suits circular buffer scheduling for fixed-size worker rotations.