12 lines
249 B
Go
12 lines
249 B
Go
package utils
|
|
|
|
// Removes the first occurence from the slice. Worst case O(n)
|
|
func RemoveFromSlice[T comparable](slice []T, item T) []T {
|
|
for i, v := range slice {
|
|
if v == item {
|
|
return append(slice[:i], slice[i+1:]...)
|
|
}
|
|
}
|
|
return slice
|
|
}
|