From dad4ab5d733b44cbe87451d0e54a66e1ff1476c5 Mon Sep 17 00:00:00 2001 From: lyb Date: Fri, 10 Aug 2018 10:19:03 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AE=BF=E9=97=AE=E4=BA=AC=E4=B8=9CAPI?= =?UTF-8?q?=EF=BC=8C=E8=8E=B7=E5=8F=96=E7=BB=93=E8=B4=A6=E5=BF=85=E8=A6=81?= =?UTF-8?q?=E4=BF=A1=E6=81=AF=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/util/Contain.go | 25 ------------------------- 1 file changed, 25 deletions(-) delete mode 100644 business/util/Contain.go diff --git a/business/util/Contain.go b/business/util/Contain.go deleted file mode 100644 index f55b945e3..000000000 --- a/business/util/Contain.go +++ /dev/null @@ -1,25 +0,0 @@ -package util - -import ( - "errors" - "reflect" -) - -// 判断obj是否在target中,target支持的类型arrary,slice,map -func Contain(obj interface{}, target interface{}) (bool, error) { - 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, nil - } - } - case reflect.Map: - if targetValue.MapIndex(reflect.ValueOf(obj)).IsValid() { - return true, nil - } - } - - return false, errors.New("not in array") -}