From bf07ab9e2fd3f0b25b6da19d7f6bc39262d84c03 Mon Sep 17 00:00:00 2001 From: boojack Date: Sat, 12 Nov 2022 11:31:16 +0800 Subject: [PATCH] fix: remove duplicate tag (#450) fix: remove dumplicate tag --- server/tag.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/server/tag.go b/server/tag.go index 33f4a680..a47e8a0e 100644 --- a/server/tag.go +++ b/server/tag.go @@ -47,9 +47,15 @@ func (s *Server) registerTagRoutes(g *echo.Group) { return echo.NewHTTPError(http.StatusInternalServerError, "Failed to find memo list").SetInternal(err) } - tagList := []string{} + tagMapSet := make(map[string]bool) for _, memo := range memoList { - tagList = append(tagList, findTagListFromMemoContent(memo.Content)...) + for _, tag := range findTagListFromMemoContent(memo.Content) { + tagMapSet[tag] = true + } + } + tagList := []string{} + for tag := range tagMapSet { + tagList = append(tagList, tag) } sort.Strings(tagList)