From 01d3221d3aadf7448ef29505654209d5c3f3ebe7 Mon Sep 17 00:00:00 2001 From: lyb Date: Fri, 10 Aug 2018 16:51:57 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AE=BF=E9=97=AE=E9=A5=BF=E4=BA=86=E4=B9=88AP?= =?UTF-8?q?I=EF=BC=8C=E8=8E=B7=E5=8F=96=E7=BB=93=E8=B4=A6=E5=BF=85?= =?UTF-8?q?=E8=A6=81=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 | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 business/util/Contain.go diff --git a/business/util/Contain.go b/business/util/Contain.go new file mode 100644 index 000000000..9966db076 --- /dev/null +++ b/business/util/Contain.go @@ -0,0 +1,15 @@ +package util + +import ( + "errors" +) + +// 判断obj是否在target中,target支持的类型arrary,slice +func ContainForInt64Arry(obj int64, target []int64) (bool, error) { + for _, value := range target { + if value == obj { + return true, nil + } + } + return false, errors.New("not in array") +}