Golang判断元素是否存在数组中

func IsContain(items []string, item string) bool {
    
    
	for _, eachItem := range items {
    
    
		if eachItem == item {
    
    
			return true
		}
	}
	return false
}

猜你喜欢

转载自blog.csdn.net/weixin_43874301/article/details/120454500