From 69f504a13d62fac9d33d766d40f8b2a23e979283 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E8=8C=B6=E6=B8=85=E6=AC=A2?= Date: Mon, 12 Jun 2023 18:47:28 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=AE=80=E5=8D=95=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E7=B1=BB=E5=9E=8B=E7=9A=84=E5=8E=BB=E9=87=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- array.go | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) 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{}{} }