增加简单数据类型的去重

This commit is contained in:
白茶清欢 2023-06-12 18:47:28 +08:00
parent 4474e9151c
commit 69f504a13d

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