Container patterns

The type parameter proposal itself mentions the container pattern — where boilerplate code is repeated for different types:

  1. type IntList []int
  2. type Int8List []int
  3. type MyTypeList []MyType

are replaced by:

  1. type List[T any] []T

Soon stdlib will start to build support into well-known packages such as sort and new packages for things like chan and slice that use generics to provide a one-stop-shop for common functionality.

The container pattern is likely the most pervasive way generics will impact Go in the immediate future.


Next: Eliminating boxing