Quidest?

Generic Types in Go

ยท Lorenzo Drumond

In addition to generic functions, Go also supports generic types. A type can be parametrized with a type parameter, which could be useful for implementing generic data structures.

1package main
2
3// List represents a singly-linked list that holds
4// values of any type
5type List[T any] struct {
6  val T
7  next *List[T]
8}

References

#generics #type #parameters #generic_types #comparable #golang #type_theory