Skip to content

Instantly share code, notes, and snippets.

@xthezealot
Created July 7, 2017 16:58
Show Gist options
  • Save xthezealot/751abe12134fbdcd78dd5bb994ad6eeb to your computer and use it in GitHub Desktop.
Save xthezealot/751abe12134fbdcd78dd5bb994ad6eeb to your computer and use it in GitHub Desktop.
Go utility functions
func mergeSlices(s1, s2 []string) []string {
if s1 == nil {
return s2
} else if s2 == nil {
return s1
}
S1Loop:
for _, e1 := range s1 {
for _, e2 := range s2 { // Avoid duplicates.
if e1 == e2 {
continue S1Loop
}
}
s2 = append(s2, e1)
}
return s2
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment