1 Star 4 Fork 0

火火/golang-common

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
arr_util.go 404 Bytes
一键复制 编辑 原始数据 按行查看 历史
火火 提交于 2019-10-29 17:14 +08:00 . 12
package utils
import "reflect"
func InArray(arr interface{}, v interface{}) bool {
vof := reflect.ValueOf(arr)
if vof.Kind() == reflect.Ptr {
vof = vof.Elem()
}
if vof.Kind() != reflect.Array && vof.Kind() != reflect.Slice {
panic("arr param must to be a array or slice")
}
le := vof.Len()
for i := 0; i < le; i++ {
if vof.Index(i).Interface() == v {
return true
}
}
return false
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/yxd1990/golang-common.git
git@gitee.com:yxd1990/golang-common.git
yxd1990
golang-common
golang-common
62252a89ea79

搜索帮助