This commit is contained in:
hantmac
2019-12-24 16:44:54 +08:00
parent 46c2f9fa69
commit ec9525cb1a
2 changed files with 5 additions and 5 deletions

View File

@@ -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,

View File

@@ -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
}
}