Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
package main
import "fmt"
func main() {
s := []string{"pig", "big", "sig", "pig", "lig", "tig", "pig", "sig", "kig", "pig"}
s = removeString(s, "pig")
fmt.Println(s)
}
func removeString(list []string, toRemove string) []string {
for i := 0; i < len(list); i++ {
if list[i] == toRemove {
list = append(list[:i], list[i+1:]...)
i--
}
}
return list
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.