this post was submitted on 20 Jul 2023
4 points (100.0% liked)

Golang

0 readers
1 users here now

This is a community dedicated to the go programming language.

Useful Links:

Rules:

founded 1 year ago
MODERATORS
 

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.

top 2 comments
sorted by: hot top controversial new old
[–] Carpet_Monster@lemmy.world 1 points 1 year ago (1 children)

probably not. Don't need it much. Using map gets you the same functionality

[–] mrh@mander.xyz 2 points 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.