个人常用函数
func IsContain(items []string, item string) bool {
for _, eachItem := range items {
if eachItem == item {
return true
}
}
return false
}
使用方法:
var word := "my"
var sentence := []string{"my","word","in","a","sentence"}
if IsContain(sentence){
//包含
}else{
//不包含
}