items
This commit is contained in:
@ -21,3 +21,18 @@ func TypeInSlice(a string, list []string) bool {
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func DeleteFromEntitySlice(haystack []Entity, needle Entity) ([]Entity, Entity) {
|
||||
var excluded Entity
|
||||
for i, _ := range haystack {
|
||||
if haystack[i] == needle {
|
||||
excluded = haystack[i]
|
||||
if len(haystack) - 1 > i {
|
||||
haystack = append(haystack[:i], haystack[i+1:] ...)
|
||||
} else {
|
||||
haystack = haystack[:i]
|
||||
}
|
||||
}
|
||||
}
|
||||
return haystack, excluded
|
||||
}
|
Reference in New Issue
Block a user