Skip to content

Commit

Permalink
fix: Preserve the original slice when removing string (argoproj#4835)
Browse files Browse the repository at this point in the history
Signed-off-by: songjuchao <[email protected]>
  • Loading branch information
Song Juchao authored Jan 7, 2021
1 parent adfa988 commit 53110b6
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion util/slice/slice.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ package slice
func RemoveString(slice []string, element string) []string {
for i, v := range slice {
if element == v {
return append(slice[:i], slice[i+1:]...)
ret := make([]string, 0, len(slice)-1)
ret = append(ret, slice[:i]...)
return append(ret, slice[i+1:]...)
}
}
return slice
Expand Down

0 comments on commit 53110b6

Please sign in to comment.