Skip to content

Instantly share code, notes, and snippets.

@arxdsilva
Created August 16, 2017 13:32
Show Gist options
  • Save arxdsilva/273776300af8487937a871cc92928317 to your computer and use it in GitHub Desktop.
Save arxdsilva/273776300af8487937a871cc92928317 to your computer and use it in GitHub Desktop.
comparing two slices in go
func compare(a, b []string) []string {
for i := len(a) - 1; i >= 0; i-- {
for _, vD := range b {
if a[i] == vD {
a = append(a[:i], a[i+1:]...)
break
}
}
}
return a
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment