From 7e6e5aaf1c35e291b57ef3f4268b6e736e37458b Mon Sep 17 00:00:00 2001 From: cuishuang Date: Fri, 27 Sep 2024 20:43:33 +0800 Subject: [PATCH] fix: fix slice init length Signed-off-by: cuishuang --- internal/dao/jinzhu/topics.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/dao/jinzhu/topics.go b/internal/dao/jinzhu/topics.go index 639f32d48..68b59f422 100644 --- a/internal/dao/jinzhu/topics.go +++ b/internal/dao/jinzhu/topics.go @@ -173,7 +173,7 @@ func (s *topicSrv) listTags(conditions *ms.ConditionsT, limit int, offset int) ( tagMap[item.UserID] = append(tagMap[item.UserID], item) res = append(res, item) } - ids := make([]int64, len(tagMap)) + ids := make([]int64, 0, len(tagMap)) for userId := range tagMap { ids = append(ids, userId) } @@ -332,7 +332,7 @@ func (s *topicSrvA) ListTags(typ cs.TagType, offset, limit int) (res cs.TagList, tagMap[item.UserID] = append(tagMap[item.UserID], item) res = append(res, item) } - ids := make([]int64, len(tagMap)) + ids := make([]int64, 0, len(tagMap)) for userId := range tagMap { ids = append(ids, userId) }