I have a slice of strings. What I need to accomplish is to remove one value from the slice, without knowing the index. I thought this would be the easiest way to do it:
// Return a slice that is the original without the given string
func newSliceWithout(s []string, without string) []string {
l := []string{}
for _, elem := range s {
if elem != without {
l = append(l, elem)
}
}
return l
}
However, when performing benchmarks I get pretty high values (as expected), so I'm wondering if there's a faster / more efficient way to do it?