diff --git a/array.go b/array.go index 5845aa8..1e2c966 100644 --- a/array.go +++ b/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{}{} }