Following from How to check if a slice is inside a slice in GO?, @Mostafa posted the following for checking if an element is in a slice:
func contains(s []string, e string) bool {
for _, a := range s {
if a == e {
return true
}
}
return false
}
Now it's a matter of checking element by element:
func subslice (s1 []string, s2 []string) bool {
if len(s1) > len(s2) { return false }
for _, e := range s1 {
if ! contains(s2,e) {
return false
}
}
return true
}
Of course, this ignores duplicates, so there's room for improvement.