Created
July 7, 2017 16:58
-
-
Save xthezealot/751abe12134fbdcd78dd5bb994ad6eeb to your computer and use it in GitHub Desktop.
Go utility functions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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