Skip to content

Latest commit

 

History

History
25 lines (15 loc) · 863 Bytes

01-container-patterns.md

File metadata and controls

25 lines (15 loc) · 863 Bytes

Container patterns

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

type IntList []int

type Int8List []int

type MyTypeList []MyType

are replaced by:

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