diff --git a/helper/slice_helper.go b/helper/slice_helper.go index 9ce4ca6..183fee8 100644 --- a/helper/slice_helper.go +++ b/helper/slice_helper.go @@ -39,3 +39,36 @@ func IsIntSlice(v interface{}) bool { _, ok := v.([]int) return ok } + +func DeleteIntSlice(a []int, elt int) []int { + var size = len(a) + for i := 0; i < size; i++ { + if a[i] == elt { + a = append(a[:i], a[i+1:]...) + i-- + } + } + return a +} + +func DeleteStrSlice(a []string, elt string) []string { + var size = len(a) + for i := 0; i < size; i++ { + if a[i] == elt { + a = append(a[:i], a[i+1:]...) + i-- + } + } + return a +} + +func DeleteSlice(a []any, elt any) []any { + var size = len(a) + for i := 0; i < size; i++ { + if a[i] == elt { + a = append(a[:i], a[i+1:]...) + i-- + } + } + return a +}