Skip to content

Commit

Permalink
SMAT-2957: fixed incompatible x/exp/slice library update
Browse files Browse the repository at this point in the history
  • Loading branch information
bigbes committed Jan 16, 2024
1 parent f68d476 commit 6bd0fbf
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 8 deletions.
14 changes: 12 additions & 2 deletions defcon/list_iterator.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ package defcon
import (
"reflect"

"golang.org/x/exp/slices"

"github.com/soverenio/vanilla/throw"
"github.com/soverenio/vanilla/zero"
"golang.org/x/exp/slices"
)

type ListIterator[E any] interface {
Expand Down Expand Up @@ -128,7 +129,16 @@ func (l *listIterator[E]) Sort(less func(E, E) bool) ListIterator[E] {
sorted = append(sorted, e)
}

slices.SortFunc(sorted, less)
slices.SortFunc(sorted, func(a, b E) int {
switch {
case less(a, b):
return -1
case less(b, a):
return 1
default:
return 0
}
})
return IteratorFromList[E](sorted)
}

Expand Down
15 changes: 13 additions & 2 deletions defcon/map_iterator.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ package defcon
import (
"reflect"

"golang.org/x/exp/slices"

"github.com/soverenio/vanilla/throw"
"github.com/soverenio/vanilla/zero"
"golang.org/x/exp/slices"
)

type MapIterator[K comparable, V any] interface {
Expand Down Expand Up @@ -266,7 +267,17 @@ func IteratorFromMap[K comparable, V any](inp map[K]V, less func(K, K) bool) Map
for key := range inp {
keys = append(keys, key)
}
slices.SortFunc(keys, less)

slices.SortFunc(keys, func(a, b K) int {
switch {
case less(a, b):
return -1
case less(b, a):
return 1
default:
return 0
}
})

pos := 0

Expand Down
3 changes: 2 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@ go 1.20
require (
github.com/gojuno/minimock/v3 v3.1.3
github.com/stretchr/testify v1.8.4
golang.org/x/exp v0.0.0-20220428152302-39d4317da171
golang.org/x/exp v0.0.0-20220827204233-334a2380cb91
)

require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/kr/pretty v0.3.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/rogpeppe/go-internal v1.11.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
7 changes: 4 additions & 3 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,13 @@ github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8=
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M=
github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUzkipdSkR5nkCZA=
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
golang.org/x/exp v0.0.0-20220428152302-39d4317da171 h1:TfdoLivD44QwvssI9Sv1xwa5DcL5XQr4au4sZ2F2NV4=
golang.org/x/exp v0.0.0-20220428152302-39d4317da171/go.mod h1:lgLbSvA5ygNOMpwM/9anMpWVlVJ7Z+cHWq/eFuinpGE=
golang.org/x/exp v0.0.0-20220827204233-334a2380cb91 h1:tnebWN09GYg9OLPss1KXj8txwZc6X6uMr6VFdcGNbHw=
golang.org/x/exp v0.0.0-20220827204233-334a2380cb91/go.mod h1:cyybsKvd6eL0RnXn6p/Grxp8F5bW7iYuBgsNCOHpMYE=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
Expand Down

0 comments on commit 6bd0fbf

Please sign in to comment.