Contracts — Draft Design presents a draft proposal for adding generic types and functions to the Go programming language, using contracts to specify the behavior required of type parameters.
The current document sketches a simple extension to that proposal, which would permit writing generic functions whose type parameters could be either built-in types or user-defined types deliberately designed to be similar to the built-in types.
Consider a generic function, say