Skip to content

Instantly share code, notes, and snippets.

@GrimTheReaper
Created January 29, 2016 21:51
Show Gist options
  • Save GrimTheReaper/df99f12dac5935cfe052 to your computer and use it in GitHub Desktop.
Save GrimTheReaper/df99f12dac5935cfe052 to your computer and use it in GitHub Desktop.
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