From 4d393d35f6adf42657d8f93d1f2ef094a94535e3 Mon Sep 17 00:00:00 2001 From: Daniel Gonzalez Date: Wed, 13 Apr 2022 19:44:54 +0200 Subject: [PATCH] fix: Do not crash in away example if away config has no settings --- examples/away/main.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/examples/away/main.go b/examples/away/main.go index e259e6e..3b01075 100644 --- a/examples/away/main.go +++ b/examples/away/main.go @@ -65,7 +65,10 @@ func main() { fmt.Println("Away Configuration:") if awayConfig.AutoAdjust { fmt.Printf("Comfort Level: %d\n", awayConfig.ComfortLevel) - fmt.Printf("Temperature: %.2f C°, %.2f F°\n", awayConfig.Setting.Temperature.Celsius, awayConfig.Setting.Temperature.Fahrenheit) + + if awayConfig.Setting != nil { + fmt.Printf("Temperature: %.2f C°, %.2f F°\n", awayConfig.Setting.Temperature.Celsius, awayConfig.Setting.Temperature.Fahrenheit) + } } // Update comfort level