I hereby claim:
- I am ulyc on github.
- I am ulyc404 (https://keybase.io/ulyc404) on keybase.
- I have a public key ASDwJPFdOFOdWKBrB_QDv9z34E9vdi8ZTrgMAsZ3r-Sgwgo
To claim this, I am signing this object:
I hereby claim:
To claim this, I am signing this object:
// 判断obj是否在target中,target支持的类型arrary, slice, map | |
func Contain(target interface{}, obj interface{}) bool { | |
targetValue := reflect.ValueOf(target) | |
switch reflect.TypeOf(target).Kind() { | |
case reflect.Slice, reflect.Array: | |
for i := 0; i < targetValue.Len(); i++ { | |
if targetValue.Index(i).Interface() == obj { | |
return true | |
} | |
} |