Generics have been around for a while now, and although this has been brought up before, do ya’ll think a built in set data type like golang-set (or something similar) will come to the stdlib? Do you think it should?

I think it would be a great convenience at little to no cost to the practicalities or philosophies of Go.

  • mrh@mander.xyzOP
    link
    fedilink
    arrow-up
    2
    ·
    1 year ago

    I find hacking maps to be sets with map[T]bool or map[T]struct{} to be awkward for the most rudimentary use case, membership checking, and downright onerous for anything more “complicated.”

    I feel as though the datastructure “an unordered collection of things without duplicates, with constant time lookup” is so simple and useful, I don’t see any reason to keep it out of the language.