go-generics

Installation
SKILL.md

Go Generics and Type Parameters


When to Use Generics

Start with concrete types. Generalize only when a second type appears.

Prefer Generics When

  • Multiple types share identical logic (sorting, filtering, map/reduce)
  • You would otherwise rely on any and excessive type switching
  • You are building a reusable data structure (concurrent-safe set, ordered map)

Avoid Generics When

  • Only one type is being instantiated in practice
  • Interfaces already model the shared behavior cleanly
  • The generic code is harder to read than the type-specific alternative
Related skills

More from cxuu/golang-skills

Installs
354
GitHub Stars
90
First Seen
Mar 14, 2026