From 0ae92a5c7564eb7101bc6edcc9367d11ba2c13df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E5=85=89=E6=98=A5?= Date: Mon, 30 May 2022 09:53:36 +0800 Subject: [PATCH] =?UTF-8?q?-=20array=EF=BC=9A=E4=BC=98=E5=8C=96=20`RemoveD?= =?UTF-8?q?uplicateElement`=20=E5=8E=BB=E9=87=8D=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- goarray/goarray.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/goarray/goarray.go b/goarray/goarray.go index 25f58598..46ababd1 100644 --- a/goarray/goarray.go +++ b/goarray/goarray.go @@ -18,9 +18,9 @@ func TurnString(ss []string) (s string) { } // RemoveDuplicateElement 去重 -func RemoveDuplicateElement(ss []string) []string { - result := make([]string, 0, len(ss)) - temp := map[string]struct{}{} +func RemoveDuplicateElement[T string | int | int16 | int32](ss []T) []T { + result := make([]T, 0, len(ss)) + temp := map[T]struct{}{} for _, item := range ss { if _, ok := temp[item]; !ok { temp[item] = struct{}{}