deckarep / golang-set

A simple, battle-tested and generic set type for the Go language. Trusted by Docker, 1Password, Ethereum and Hashicorp.
Other
4.15k stars 274 forks source link

Feature request: Support for immutable sets #109

Closed nikist97 closed 1 year ago

nikist97 commented 1 year ago

Hello, are there any considerations for supporting an immutable set? I am thinking something similar to the Guava Java implementation - https://guava.dev/releases/19.0/api/docs/com/google/common/collect/ImmutableSet.html

deckarep commented 1 year ago

Hello,

On the subject of immutability I do prefer collections that have immutable variants but the only reason why this doesn't exist in this package is I'm not sure the Go language has great language semantics to actually build properly immutable data structures. I would be open to it but would argue that Go is not an ideal language for this.

Perhaps this could change in the future if Go has good language semantics to support immutability properly.

Thanks for the message!

-deckarep