New package with a generic set type has been accepted :)…

Переслано изGO🇺🇦 Go for two :)
New package with a generic set type has been accepted :)
https://github.com/golang/go/issues/69230

package set // import "golang.org/x/exp/collection/set"

Package set defines Set, an experimental prototype for what may become the
canonical representation of a set recommended for use in public APIs.

A Set[E] is transparently represented as a map[E]struct{}, and so it may be used
as the operand of a range loop.

Example:

var x, y, z set.Set[int]
x = set.Of(1, 2, 3) // "{1, 2, 3}"
y = set.Of(3, 4, 5) // "{3, 4, 5"}
z = x.Intersection(y) // "{3}"
for elem := range z {
println(elem) // "3"
}
// more examples https://github.com/golang/go/issues/69230#issuecomment-6040903375
GitHub
golang.org/x/exp/collection/set: new package with a generic set type · Issue #69230 · golang/go
(Please see the pinned comment below for recent updates. 7 Oct 2026. --jba) (Please see #69230 (comment) below for the API recommended by the Collections working group. --adonovan, Jul 2026.) This ...
6 ноября 2026 г. 809 1 4
New package with a generic set type has been accepted :)… — myStack — TG.ME