golang-data-structures

Explain Go slice, map, and container internals for performance-sensitive code.

5|1|Updated Apr 14, 2026
One-click install
npx skills add https://github.com/omarluq/og-template --skill golang-data-structures-omarluq
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: golang-data-structures
Source: https://github.com/omarluq/og-template/tree/main/.agents/skills/golang-data-structures
Command: npx skills add https://github.com/omarluq/og-template --skill golang-data-structures-omarluq

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Golang data structures clarity: slices, maps, arrays, and containers explained with internal details, guiding you to write efficient, correct Go code.

Core Features & Use Cases

  • Slice internals, capacity growth, and preallocation guidance for performance.
  • Map and hash internals, allocation strategies, and memory considerations.
  • Containers and standard library primitives (container/heap, container/list, container/ring) usage patterns.
  • Pointer types, weak pointers, and copy semantics for high-throughput code.
  • Generics and constraints in Go 1.18+, with practical patterns for generic containers.
  • Cross-references to deeper deep-dives and safety considerations.

Quick Start

Study the Go data structures guide to choose the right slice, map, or container for your performance-sensitive code.

Frequently Asked Questions about golang-data-structures

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

FAQPage Schema
How do Go slices work internally and when should I preallocate capacity?

Go slices use an underlying array with a header tracking length and capacity. Preallocate slice capacity using `make` when the final size is known, preventing repeated memory allocation and copy overhead during growth.

What's the best way to choose between maps and slices for performance in Go?

Choose slices for sequential access and maps for key-based lookups. Go maps handle hash collisions via linked lists and allocate memory dynamically, making slices more memory-efficient for ordered, index-based data.

How do I use generics to build custom data containers in Go?

Use Go 1.18+ generics and type constraints to define reusable data containers. This allows type-safe, generic data structures without runtime type assertions, optimizing memory layout and compile-time safety.

Does Go support weak pointers for high-throughput memory management?

Yes, Go supports weak pointers to manage references without preventing garbage collection. This optimizes high-throughput code by allowing the runtime to reclaim memory from unused objects automatically.

When should I use container/heap versus container/list in Go?

Use container/heap for priority queues requiring ordered retrieval, and container/list for doubly-linked sequential data. These standard library primitives provide specific memory layout and traversal performance characteristics.