Skip to content
masterclass Buddy

Go · Concept

Generics

Go generics let one function or type work with a permitted set of types. Type constraints limit the choices, and Go can often infer type arguments from function arguments.

Last updated

Since
Go 1.18

Syntax

func SumNumbers[K comparable, V Number](m map[K]V) V

In-depth API docs are only for subscribers: parameters, examples, common mistakes and interview practice.

Subscribe
  • type parameters
  • type constraints
  • type inference
  • interfaces
  • comparable
  • SumIntsOrFloats
  • SumNumbers

Source: Tutorial: Getting started with generics. Checked 2026-11-03.