增加简单数据类型的去重

This commit is contained in:
zhangdeman committed 2023-06-12 18:47:28 +08:00
1 parent 4474e9151c
commit 69f504a13d
1 file changed
+15 -1
+15 -1
View File
@@ -10,6 +10,7 @@ package wrapper
import (
"encoding/json"
"errors"
"fmt"
"reflect"
"strings"
)
@@ -211,6 +212,19 @@ func (at *ArrayType) Convert() {
//
// Date : 17:43 2023/6/12
func (at *ArrayType) Unique() []interface{} {
result := make([]interface{}, 0)
if at.isSimpleSlice {
// 简单数据类型
dataTable := make(map[string]bool)
for _, item := range at.convertResult {
k := fmt.Sprintf("%v", item)
if _, exist := dataTable[k]; exist {
continue
}
dataTable[k] = true
result = append(result, item)
}
return result
}
return []interface{}{}
}
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.