fixed null to string error in index

This commit is contained in:
BroodjeAap 2023-02-10 14:42:36 +00:00
parent d613ef01fb
commit c20afe3425

View file

@ -3,6 +3,7 @@ package web
import ( import (
"bytes" "bytes"
"compress/gzip" "compress/gzip"
"database/sql"
"embed" "embed"
"encoding/json" "encoding/json"
"errors" "errors"
@ -456,14 +457,16 @@ func (web *Web) index(c *gin.Context) {
} else { } else {
for rows.Next() { for rows.Next() {
var watchID uint var watchID uint
var _time string var _time sql.NullString
var value string var value sql.NullString
err := rows.Scan(&watchID, &_time, &value) err := rows.Scan(&watchID, &_time, &value)
if err != nil { if err != nil {
log.Println(err) log.Println(err)
continue continue
} }
watchMap[watchID].LastValue = value if value.Valid {
watchMap[watchID].LastValue = value.String
}
} }
} }