Go 1.28 Proposal: New Generic Collection Types for the Standard Library
Golang proposal: container/: generic collection types
The Go Collections working group presents a proposal to add generic collection types to the standard library for Go 1.28. We aim to introduce hash-based maps and sets, ordered maps, and a simplified heap API while maintaining Go's principles of pragmatism and simplicity. These additions address the current lack of built-in data structures like sets and ordered maps, leveraging generics and iterators to provide ergonomic, high-performance tools for developers.
We expect it to become the standard set in most new Go APIs.
- DarkNova6
Step by step, Go is now learning the hard lessons every other language has learned over the last 20 years. The fact that despite their best efforts, their propositions look like everone else is a surprisingly refreshing affirmation of status quo.
- nasretdinov
Well, better late than never. Stuff like sets or a typed heap is long overdue. Maybe they'll even add iterator API for database/sql results this decade too (something like my pull request for sqlx https://github.com/jmoiron/sqlx/pull/990 but maybe more polished)
- kamma4434
Welcome to Java, where Collections are the bread and butter of every programmer since 1998.
While you are at it, I humbly suggest to add composable streams too, that we had in 2014, and that make working with collections way more pleasant.
(Jokes aside, in Java it is very nice that you can start with a generic ArrayList and turn it into a linked list with one single keyword change and no code needs changing, or that you can turn any collection into a synchtonized or readonly doppelganger with one line of code. Collections are nice and I miss them in Golang)
- valcron1000
22 years late, but better late than never.
- jiehong
Well, finally!
I wish they wouldn’t mix mutation methods in there, but ok.
- athorax
On one hand I'm glad to see this being added, but its becoming obvious building generics into the language as-is just isn't a good fit. Hopefully Go v2 can solve this at a more foundational level while still allowing interop or easy porting form current go code.
- alfiedotwtf
No reference to Canadian Aboriginal characters in the comments :(
- troupo
Go is rediscovering Guy Steele's Growing a Language from first principles, at a much slower pace: https://youtu.be/_ahvzDzKdB0?is=qZdfiT3792XyHxSJ