go-generics

Decide when to use Go generics over concrete types or interfaces.

8|Updated Jun 5, 2026
One-click install
npx skills add https://github.com/muratmirgun/gophers --skill go-generics
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: go-generics
Source: https://github.com/muratmirgun/gophers/tree/main/skills/go-generics
Command: npx skills add https://github.com/muratmirgun/gophers --skill go-generics

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill helps you decide when Go generics are actually justified, so you avoid overengineering simple code and only generalize when multiple real call sites need the same logic.

Core Features & Use Cases

  • Generics decision guidance: Distinguishes between concrete code, interfaces, and generics so you choose the simplest correct design.
  • Constraint selection: Recommends standard constraints like any, comparable, and cmp.Ordered instead of custom unions when possible.
  • Type design guardrails: Covers type parameter naming, type aliases versus definitions, and common anti-patterns such as generic wrappers around stdlib containers.
  • Practical examples: Helps with utility functions, reusable algorithms, typed collections, and cases where concrete types or interfaces are a better fit.

Quick Start

Ask the assistant to review a Go function or API and tell you whether it should stay concrete, use an interface, or be rewritten with generics.

Frequently Asked Questions about go-generics

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

FAQPage Schema
When should I use Go generics instead of concrete types or interfaces?

Use Go generics only when multiple real call sites require identical logic across different types, avoiding overengineering simple code and skipping unnecessary generic wrappers.

How do I choose the right constraints for Go type parameters?

Choose standard constraints like any, comparable, and cmp.Ordered for Go type parameters instead of custom unions, applying them to utility functions and reusable algorithms to maintain simplicity.

What is the best way to design a typed collection API in Go?

Designing a typed collection API in Go requires deciding whether concrete types, interfaces, or generics fit best, while following type parameter naming conventions and avoiding stdlib container wrappers.

Why does my generic wrapper around a stdlib container cause design issues?

Generic wrappers around stdlib containers cause design issues because they add unnecessary abstraction, whereas using concrete types or interfaces often provides a simpler and more correct API design.

When should I not use generics in my Go API design?

Avoid using generics in Go API design when a single concrete type suffices or when interfaces handle the polymorphism naturally, preventing unnecessary type parameters and interface-satisfaction anti-patterns.