From a268e0b48be5a6ea9926f305c254d6c364a991a8 Mon Sep 17 00:00:00 2001 From: spiritlhl <103393591+spiritLHLS@users.noreply.github.com> Date: Fri, 11 Apr 2025 14:17:28 +0000 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=9B=B4=E6=96=B0=E5=87=BD=E6=95=B0?= =?UTF-8?q?=E8=AF=B4=E6=98=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bk/utils.go | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/bk/utils.go b/bk/utils.go index 5d3d2cf..2247feb 100644 --- a/bk/utils.go +++ b/bk/utils.go @@ -17,18 +17,19 @@ type Result struct { s string } +// removeDuplicates 切片元素去重 func removeDuplicates(elements []string) []string { - encountered := map[string]bool{} // 用于存储已经遇到的元素 - result := []string{} // 存储去重后的结果 - for v := range elements { // 遍历切片中的元素 - if encountered[elements[v]] == true { // 如果该元素已经遇到过 + encountered := map[string]bool{} + result := []string{} + for v := range elements { + if encountered[elements[v]] { // 存在过就不加入了 } else { - encountered[elements[v]] = true // 将该元素标记为已经遇到 - result = append(result, elements[v]) // 将该元素加入到结果切片中 + encountered[elements[v]] = true + result = append(result, elements[v]) } } - return result // 返回去重后的结果切片 + return result } // getData 获取目标地址的文本内容