Skip to content

Commit

Permalink
Fix: Intn Panic when the len is 0 (#617)
Browse files Browse the repository at this point in the history
  • Loading branch information
foxwhite25 committed Mar 11, 2023
1 parent cc26eb1 commit e1591c4
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions plugin/coser/coser.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ func init() {
return "", err
}
arr := gjson.Get(helper.BytesToString(data), "data.data").Array()
if len(arr) == 0 {
return "", errors.New("data is empty")
}
pic := arr[rand.Intn(len(arr))]
return pic.String(), nil
}, web.GetData, time.Minute)
Expand Down

0 comments on commit e1591c4

Please sign in to comment.