|
|
@@ -40,6 +40,7 @@ import (
|
|
|
"path/filepath"
|
|
|
"regexp"
|
|
|
"runtime"
|
|
|
+ "slices"
|
|
|
"strconv"
|
|
|
"strings"
|
|
|
"time"
|
|
|
@@ -137,18 +138,6 @@ func Contains[T comparable](elems []T, v T) bool {
|
|
|
return false
|
|
|
}
|
|
|
|
|
|
-// Remove removes an element from a string slice and
|
|
|
-// returns the modified slice
|
|
|
-func Remove(elems []string, val string) []string {
|
|
|
- for idx, v := range elems {
|
|
|
- if v == val {
|
|
|
- elems[idx] = elems[len(elems)-1]
|
|
|
- return elems[:len(elems)-1]
|
|
|
- }
|
|
|
- }
|
|
|
- return elems
|
|
|
-}
|
|
|
-
|
|
|
// IsStringPrefixInSlice searches a string prefix in a slice and returns true
|
|
|
// if a matching prefix is found
|
|
|
func IsStringPrefixInSlice(obj string, list []string) bool {
|
|
|
@@ -912,3 +901,18 @@ func ReadConfigFromFile(name, configDir string) (string, error) {
|
|
|
}
|
|
|
return strings.TrimSpace(BytesToString(val)), nil
|
|
|
}
|
|
|
+
|
|
|
+// SlicesEqual checks if the provided slices contain the same elements,
|
|
|
+// also in different order.
|
|
|
+func SlicesEqual(s1, s2 []string) bool {
|
|
|
+ if len(s1) != len(s2) {
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ for _, v := range s1 {
|
|
|
+ if !slices.Contains(s2, v) {
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return true
|
|
|
+}
|