diff --git a/go.mod b/go.mod index 18a0281e..374a9923 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ go 1.23.0 require ( github.com/BurntSushi/toml v1.5.0 github.com/Masterminds/semver/v3 v3.3.1 - github.com/deckarep/golang-set/v2 v2.7.0 + github.com/deckarep/golang-set/v2 v2.8.0 github.com/jedib0t/go-pretty/v6 v6.6.5 github.com/openshift/api v0.0.0-20230120195050-6ba31fa438f2 github.com/openshift/oc v0.0.0-alpha.0.0.20230323133703-92b1a3d0e5d0 diff --git a/go.sum b/go.sum index ee0c7e4f..db90f1e9 100644 --- a/go.sum +++ b/go.sum @@ -328,8 +328,8 @@ github.com/davecgh/go-spew v0.0.0-20161028175848-04cdfd42973b/go.mod h1:J7Y8YcW2 github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/deckarep/golang-set/v2 v2.7.0 h1:gIloKvD7yH2oip4VLhsv3JyLLFnC0Y2mlusgcvJYW5k= -github.com/deckarep/golang-set/v2 v2.7.0/go.mod h1:VAky9rY/yGXJOLEDv3OMci+7wtDpOF4IN+y82NBOac4= +github.com/deckarep/golang-set/v2 v2.8.0 h1:swm0rlPCmdWn9mESxKOjWk8hXSqoxOp+ZlfuyaAdFlQ= +github.com/deckarep/golang-set/v2 v2.8.0/go.mod h1:VAky9rY/yGXJOLEDv3OMci+7wtDpOF4IN+y82NBOac4= github.com/denis-tingajkin/go-header v0.4.2/go.mod h1:eLRHAVXzE5atsKAnNRDB90WHCFFnBUn4RN0nRcs1LJA= github.com/denverdino/aliyungo v0.0.0-20190125010748-a747050bb1ba/go.mod h1:dV8lFg6daOBZbT6/BDGIz6Y3WFGn8juu6G+CQ6LHtl0= github.com/dgrijalva/jwt-go v0.0.0-20170104182250-a601269ab70c/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= diff --git a/vendor/github.com/deckarep/golang-set/v2/README.md b/vendor/github.com/deckarep/golang-set/v2/README.md index bb691b1c..e4713680 100644 --- a/vendor/github.com/deckarep/golang-set/v2/README.md +++ b/vendor/github.com/deckarep/golang-set/v2/README.md @@ -9,6 +9,11 @@ The missing `generic` set collection for the Go language. Until Go has sets bui ## Psst * Hi there, 👋! Do you use or have interest in the [Zig programming language](https://ziglang.org/) created by Andrew Kelley? If so, the golang-set project has a new sibling project: [ziglang-set](https://github.com/deckarep/ziglang-set)! Come check it out! +## Update 3/14/2025 +* Packaged version: `2.8.0` introduces support for true iterators for Go 1.23+. Please see [issue #141](https://github.com/deckarep/golang-set/issues/141) +for further details on the implications of how iterations work between older Go versions vs newer Go versions. Additionally, this +release has a minor unit-test spelling fix. + ## Update 12/3/2024 * Packaged version: `2.7.0` fixes a long-standing bug with *JSON Unmarshaling*. A large refactor in the interest of performance introduced this bug and there was no way around it but to revert the code back to how it was previously. The performance diff --git a/vendor/github.com/deckarep/golang-set/v2/set.go b/vendor/github.com/deckarep/golang-set/v2/set.go index 292089dc..e9409aa8 100644 --- a/vendor/github.com/deckarep/golang-set/v2/set.go +++ b/vendor/github.com/deckarep/golang-set/v2/set.go @@ -73,6 +73,10 @@ type Set[T comparable] interface { // given items are in the set. ContainsAny(val ...T) bool + // ContainsAnyElement returns whether at least one of the + // given element are in the set. + ContainsAnyElement(other Set[T]) bool + // Difference returns the difference between this set // and other. The returned set will contain // all elements of this set that are not also @@ -253,3 +257,13 @@ func NewThreadUnsafeSetFromMapKeys[T comparable, V any](val map[T]V) Set[T] { return s } + +// Elements returns an iterator that yields the elements of the set. Starting +// with Go 1.23, users can use a for loop to iterate over it. +func Elements[T comparable](s Set[T]) func(func(element T) bool) { + return func(yield func(element T) bool) { + s.Each(func(t T) bool { + return !yield(t) + }) + } +} diff --git a/vendor/github.com/deckarep/golang-set/v2/threadsafe.go b/vendor/github.com/deckarep/golang-set/v2/threadsafe.go index 93f20c86..664fc611 100644 --- a/vendor/github.com/deckarep/golang-set/v2/threadsafe.go +++ b/vendor/github.com/deckarep/golang-set/v2/threadsafe.go @@ -82,6 +82,19 @@ func (t *threadSafeSet[T]) ContainsAny(v ...T) bool { return ret } +func (t *threadSafeSet[T]) ContainsAnyElement(other Set[T]) bool { + o := other.(*threadSafeSet[T]) + + t.RLock() + o.RLock() + + ret := t.uss.ContainsAnyElement(o.uss) + + t.RUnlock() + o.RUnlock() + return ret +} + func (t *threadSafeSet[T]) IsEmpty() bool { return t.Cardinality() == 0 } diff --git a/vendor/github.com/deckarep/golang-set/v2/threadunsafe.go b/vendor/github.com/deckarep/golang-set/v2/threadunsafe.go index 7e3243b2..c95d32b4 100644 --- a/vendor/github.com/deckarep/golang-set/v2/threadunsafe.go +++ b/vendor/github.com/deckarep/golang-set/v2/threadunsafe.go @@ -109,6 +109,26 @@ func (s *threadUnsafeSet[T]) ContainsAny(v ...T) bool { return false } +func (s *threadUnsafeSet[T]) ContainsAnyElement(other Set[T]) bool { + o := other.(*threadUnsafeSet[T]) + + // loop over smaller set + if s.Cardinality() < other.Cardinality() { + for elem := range *s { + if o.contains(elem) { + return true + } + } + } else { + for elem := range *o { + if s.contains(elem) { + return true + } + } + } + return false +} + // private version of Contains for a single element v func (s *threadUnsafeSet[T]) contains(v T) (ok bool) { _, ok = (*s)[v] diff --git a/vendor/modules.txt b/vendor/modules.txt index d8758d0d..7ada0aac 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -153,7 +153,7 @@ github.com/containers/storage/pkg/unshare # github.com/davecgh/go-spew v1.1.1 ## explicit github.com/davecgh/go-spew/spew -# github.com/deckarep/golang-set/v2 v2.7.0 +# github.com/deckarep/golang-set/v2 v2.8.0 ## explicit; go 1.18 github.com/deckarep/golang-set/v2 # github.com/docker/distribution v2.8.2+incompatible