From e228983e7306a6e854379f42b49d6f1a37e66fb8 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, 6 May 2024 15:00:32 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96uniqueue=E8=BF=94=E5=9B=9E?= =?UTF-8?q?=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- array.go | 10 +++------- array_test.go | 4 ++-- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/array.go b/array.go index 98076f6..9604988 100644 --- a/array.go +++ b/array.go @@ -65,8 +65,8 @@ func (at *Array[Bt]) ToStringSlice() []string { // Author : go_developer@163.com<白茶清欢> // // Date : 17:43 2023/6/12 -func (at *Array[Bt]) Unique() StringResult { - result := make([]any, 0) +func (at *Array[Bt]) Unique() []Bt { + result := make([]Bt, 0) dataTable := make(map[string]bool) for _, item := range at.value { @@ -81,11 +81,7 @@ func (at *Array[Bt]) Unique() StringResult { dataTable[k] = true result = append(result, item) } - byteData, _ := json.Marshal(result) - return StringResult{ - Value: string(byteData), - Err: nil, - } + return result } diff --git a/array_test.go b/array_test.go index 032d65e..86d4258 100644 --- a/array_test.go +++ b/array_test.go @@ -13,6 +13,6 @@ import ( ) func TestArray_Unique(t *testing.T) { - fmt.Println(ArrayType([]any{"1", 1, 1, "1", 2, 3}).Unique().Value) - fmt.Println(ArrayType([]int{1, 1, 2, 3}).Unique().Value) + fmt.Println(ArrayType([]any{"1", 1, 1, "1", 2, 3}).Unique()) + fmt.Println(ArrayType([]int{1, 1, 2, 3}).Unique()) }