Try resolving pointer error.
All checks were successful
Build Docker image / build (push) Successful in 55s

This commit is contained in:
Pieter Hollander 2024-02-20 16:23:41 +01:00
parent 4aa065ee82
commit 38691f4e85
Signed by: pieter
SSH key fingerprint: SHA256:HbX+9cBXsop9SuvL+mELd29sK+7DehFfdVweFVDtMSg

10
main.go
View file

@ -73,11 +73,9 @@ type Payload struct {
}
var db *sql.DB
var logger *slog.Logger
var logger = slog.New(slog.NewJSONHandler(os.Stdout, nil))
func main() {
// Setup slog
logger := slog.New(slog.NewJSONHandler(os.Stdout, nil))
slog.SetDefault(logger)
// Load environment variables from .env file if it exists
@ -156,12 +154,6 @@ func mqttMessageHandler(client mqtt.Client, msg mqtt.Message) {
return
}
// payload.Dt1 = updateFieldIfChanged(payload.Dt1, &prevDt1)
// payload.Dt2 = updateFieldIfChanged(payload.Dt2, &prevDt2)
// payload.Rt1 = updateFieldIfChanged(payload.Rt1, &prevRt1)
// payload.Rt2 = updateFieldIfChanged(payload.Rt2, &prevRt2)
// payload.G = updateFieldIfChanged(payload.G, &prevG)
var changed bool // Flag to track if any value changed
// Update each field, directly updating `changed` if any change is detected