From 8888e71d1b40b32ba8a5503779a53f0104414a87 Mon Sep 17 00:00:00 2001 From: hantmac Date: Tue, 24 Dec 2019 16:44:54 +0800 Subject: [PATCH] fix --- backend/services/node.go | 2 +- backend/utils/helpers.go | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/backend/services/node.go b/backend/services/node.go index edaf9f16..d14ce4ae 100644 --- a/backend/services/node.go +++ b/backend/services/node.go @@ -171,7 +171,7 @@ func UpdateNodeData() { //先获取所有Redis的nodekey list, _ := database.RedisClient.HKeys("nodes") - if i := utils.Contains(list, key); i != -1 { + if i := utils.Contains(list, key); i == false { // 构造节点数据 data := Data{ Key: key, diff --git a/backend/utils/helpers.go b/backend/utils/helpers.go index ce29e4b7..e181c66c 100644 --- a/backend/utils/helpers.go +++ b/backend/utils/helpers.go @@ -42,19 +42,19 @@ func Close(c io.Closer) { } } -func Contains(array interface{}, val interface{}) (index int) { - index = -1 +func Contains(array interface{}, val interface{}) (fla bool) { + fla = false switch reflect.TypeOf(array).Kind() { case reflect.Slice: { s := reflect.ValueOf(array) for i := 0; i < s.Len(); i++ { if reflect.DeepEqual(val, s.Index(i).Interface()) { - index = i + fla = true return } } } } return -} \ No newline at end of file +}