123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- package utils
- import "reflect"
- func Contains(a interface{}, b interface{}) bool {
- if reflect.ValueOf(a).Len() == 0 {
- return false
- }
- if _, ok := b.(int); ok {
- if tempB, ok := a.([]int); ok {
- for _, v := range tempB {
- if b == v {
- return true
- }
- }
- }
- }
- if _, ok := b.(uint); ok {
- if tempB, ok := a.([]uint); ok {
- for _, v := range tempB {
- if b == v {
- return true
- }
- }
- }
- }
- if _, ok := b.(float32); ok {
- if tempB, ok := a.([]float32); ok {
- for _, v := range tempB {
- if b == v {
- return true
- }
- }
- }
- }
- if _, ok := b.(string); ok {
- if tempB, ok := a.([]string); ok {
- for _, v := range tempB {
- if b == v {
- return true
- }
- }
- }
- }
- return false
- }
|