Golang data structures — slices (internals, capacity growth, preallocation, slices package), maps (internals, hash buckets, maps package), arrays, container/list/heap/ring, strings.Builder vs bytes.Buffer, generic collections, pointers (unsafe.Pointer, weak.Pointer), and copy semantics.
SkillScore100Maintained
Automatic
◆Coding pack
Last verified 9/9/2026
What it changes
Passed 22 of 22 test cases with the skill, and 20 of 22 without it.
Without skill91%
With skill100%
Checks it passed that the model alone missed
Recommends using a fixed-size array as the map key.
Recommends slice initialization using make with zero length and explicit capacity.
2 fixed20 passed either way0 still failing0 broke
Pass-rate lift
+9 pp
Tokens
+131%
Agent turns
0%
Response time
-7%
Model gemini-3.6-flashMeasured 9/9/2026v222 of 22 cases passed with skill
Tokens, turns and time describe resource use, not a dollar price.
See it in action
One of 2 test cases the skill fixed. Same model, same prompt, with and without the skill.
1 of 2
Prompt
We need an in-memory cache key in Go representing 2D grid coordinates `(x, y)` of integers. A developer suggested formatting them as strings with `fmt.Sprintf("%d,%d", x, y)` to use as keys in `map[string]Value`. What zero-allocation Go data structure can serve directly as map keys without string conversions?
What was checked, without and with the skill
Checked
Without skill
With skill
Recommends using a fixed-size array as the map key.
Missed
Passed
case-04 · gemini-3.6-flash · 9/9/2026 · answers are capped and redacted
What's inside
The instructions your model reads when the skill loads.
SKILL.md173 lines6 files
Persona: You are a Go engineer who understands data structure internals. You choose the right structure for the job — not the most familiar one — by reasoning about memory layout, allocation cost, and access patterns.
Go Data Structures
Built-in and standard library data structures: internals, correct usage, and selection guidance.
For safety pitfalls (nil maps, append aliasing, defensive copies) see samber/cc-skills-golang@golang-safety skill.
For channels and sync primitives see samber/cc-skills-golang@golang-concurrency skill.
For string/byte/rune choice see samber/cc-skills-golang@golang-design-patterns skill.
Best Practices Summary
Preallocate slices and maps with make(T, 0, n) / make(map[K]V, n) when size is known or estimable — avoids repeated growth copies and rehashing
Arrays SHOULD be preferred over slices only for fixed, compile-time-known sizes (hash digests, IPv4 addresses, matrix dimensions)
NEVER rely on slice capacity growth timing — the growth algorithm changed between Go versions and may change again; your code should not depend on when a new backing array is allocated
Use container/heap for priority queues, container/list only when frequent middle insertions are needed, container/ring for fixed-size circular buffers
strings.Builder MUST be preferred for building strings; bytes.Buffer MUST be preferred for bidirectional I/O (implements both io.Reader and io.Writer)
Generic data structures SHOULD use the tightest constraint possible — comparable for keys, custom interfaces for ordering
unsafe.Pointer MUST only follow the 6 valid conversion patterns from the Go spec — NEVER store in a uintptr variable across statements
weak.Pointer[T] (Go 1.24+) SHOULD be used for caches and canonicalization maps to allow GC to reclaim entries
Slice Internals
A slice is a 3-word header: pointer, length, capacity. Multiple slices can share a backing array (→ see samber/cc-skills-golang@golang-safety for aliasing traps and the header diagram).
Idiomatic Golang design patterns — functional options, constructors, error flow and cascading, resource management and lifecycle, graceful shutdown, resilience, architecture, dependency injection, data handling, streaming, and more. Apply when explicitly choosing between architectural patterns, implementing functional options, designing constructor APIs, setting up graceful shutdown, applying resilience patterns, or asking which idiomatic Go pattern fits a specific problem.