Add generic collection packages (experimental)
Go has few library collection types. Sets are usually written as map[T]bool or map[T]struct{}, ordered maps don't exist, and container/heap is awkward to use. This umbrella proposal adds a family of generic collection packages to golang.org/x/exp, so the community can try them before they move into the standard library.
The new types are:
- set.Set: a set of comparable elements, backed by
map[T]struct{}. It is meant to become the standard set type in new APIs. - hashed.Map and hashed.Set: collections that use custom hash and equality functions.
- sorted.Map and sorted.Set: ordered collections, useful for range queries.
- heap.Heap: a generic replacement for
container/heap. - Insertion-ordered map, which iterates in the order items were added.
See individual proposals for more details.
- Proposal
- #80590 by adonovan
- Status
- Accepted on Nov 4, 2026
- Impact
- medium
- Area
- x/exp/collection