From 037e17569f49cc9ecea1ef1f5ca5c966e2a0a547 Mon Sep 17 00:00:00 2001 From: BaoXuebin Date: Sun, 10 Mar 2024 23:42:22 +0800 Subject: [PATCH] =?UTF-8?q?fixbug:=20=E6=8D=A2=E8=A1=8C=E7=AC=A6=E5=AF=BC?= =?UTF-8?q?=E8=87=B4=E7=9A=84=E6=95=B0=E7=BB=84=E8=B6=8A=E7=95=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- service/events.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/service/events.go b/service/events.go index 9530940..f36fa52 100644 --- a/service/events.go +++ b/service/events.go @@ -49,6 +49,9 @@ func GetAllEvents(c *gin.Context) { } // split line by " " words := strings.Fields(line) + if len(words) < 4 { + continue + } if words[1] != "event" { continue } @@ -58,8 +61,10 @@ func GetAllEvents(c *gin.Context) { Description: strings.ReplaceAll(words[3], "\"", ""), }) } - // events 按时间倒序排列 - sort.Sort(sort.Reverse(events)) + if len(events) > 0 { + // events 按时间倒序排列 + sort.Sort(sort.Reverse(events)) + } OK(c, events) }