增加简单数据类型的去重
This commit is contained in:
parent
4474e9151c
commit
69f504a13d
16
array.go
16
array.go
@ -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{}{}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user