From 23125bea5e52f9246d3ccc54a1834f672780a60c Mon Sep 17 00:00:00 2001 From: Florian Baumann Date: Tue, 19 Mar 2024 11:39:08 +0100 Subject: [PATCH] Fix bug of empty result --- pkg/serra/web.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pkg/serra/web.go b/pkg/serra/web.go index 6e021af..ffeaa4f 100644 --- a/pkg/serra/web.go +++ b/pkg/serra/web.go @@ -89,7 +89,12 @@ func landingPage(c *gin.Context) { }}}, }) defer storageDisconnect(client) - numCards := counts[0]["count"].(int32) + + // Catch index error on no results + var numCards int32 + if len(counts) != 0 { + numCards = counts[0]["count"].(int32) + } c.HTML(http.StatusOK, "index.tmpl", gin.H{ "title": "Serra",