Robust generic functions on slices - The Go Programming Language
The Go Blog
The slices package provides functions that work for slices of any type.
In this blog post we’ll discuss how you can use these functions more effectively by understanding how slices are represented in memory and how that affects the garbage collector, and we’ll cover how we recently adjusted these functions to make them less surprising.
With Type parameters we can write functions like slices.Index once for all types of slices of comparable elements:
// Index returns the index of the f...
Read more at go.dev