Skip to content

Commit

Permalink
fixbug: 换行符导致的数组越界
Browse files Browse the repository at this point in the history
  • Loading branch information
BaoXuebin committed Mar 10, 2024
1 parent 9012ef6 commit 037e175
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions service/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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)
}

Expand Down

0 comments on commit 037e175

Please sign in to comment.