aboutsummaryrefslogtreecommitdiff
path: root/go/utils
diff options
context:
space:
mode:
Diffstat (limited to 'go/utils')
-rw-r--r--go/utils/slices.go13
1 files changed, 13 insertions, 0 deletions
diff --git a/go/utils/slices.go b/go/utils/slices.go
index 3cc38c1c..eb02f782 100644
--- a/go/utils/slices.go
+++ b/go/utils/slices.go
@@ -15,3 +15,16 @@ func InterfaceSliceToTypedSlice[T any](s []interface{}) []T {
}
return ts
}
+
+func RemoveFromUnorderedSlice[T comparable](s []T, o T) []T {
+ for i, t := range s {
+ if t != o {
+ continue
+ }
+
+ s[i] = s[len(s) - 1]
+ return s[:len(s) - 1]
+ }
+
+ return s
+}