From c20afe34252c99dccb43dbe573ea5f7beecb7d7c Mon Sep 17 00:00:00 2001 From: BroodjeAap Date: Fri, 10 Feb 2023 14:42:36 +0000 Subject: [PATCH] fixed null to string error in index --- web/web.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/web/web.go b/web/web.go index 33b3138..24ef5b2 100644 --- a/web/web.go +++ b/web/web.go @@ -3,6 +3,7 @@ package web import ( "bytes" "compress/gzip" + "database/sql" "embed" "encoding/json" "errors" @@ -456,14 +457,16 @@ func (web *Web) index(c *gin.Context) { } else { for rows.Next() { var watchID uint - var _time string - var value string + var _time sql.NullString + var value sql.NullString err := rows.Scan(&watchID, &_time, &value) if err != nil { log.Println(err) continue } - watchMap[watchID].LastValue = value + if value.Valid { + watchMap[watchID].LastValue = value.String + } } }