cmd/info: Use 'info' struct

This commit is contained in:
Tom Wiesing 2022-10-03 13:37:36 +02:00
parent ea714aba86
commit 894c23c137
No known key found for this signature in database
3 changed files with 53 additions and 10 deletions

View file

@ -2,9 +2,20 @@ package slicesx
import (
"golang.org/x/exp/constraints"
"golang.org/x/exp/maps"
"golang.org/x/exp/slices"
)
// ForSorted iterates over the map in an ordered fashion
func ForSorted[K constraints.Ordered, V any](mp map[K]V, callback func(k K, v V)) {
keys := maps.Keys(mp)
slices.Sort(keys)
for _, key := range keys {
callback(key, mp[key])
}
}
// Any returns true if test returns true for any of values.
func Any[T any](values []T, test func(T) bool) bool {
for _, v := range values {