Golang: Check if some array sting contains a given string.
package main
import "sort"
func ArrayStringContain(array []string, s string) bool {
idx := sort.SearchStrings(array, s)
return idx < len(array) && array[idx] == s
}
func main() {
var data = []string{"work", "from", "home"}
if ArrayStringContain(data, "home") {
println("Yes it contain 'home'!")
}
}