From 8f06b860fa2f5d803d6661258721cdc3eab7c183 Mon Sep 17 00:00:00 2001 From: Elis Hirwing Date: Sat, 4 Nov 2017 22:04:13 +0100 Subject: [PATCH] Do not crash if weather output is too short --- src/statusscreen/Weather.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/statusscreen/Weather.go b/src/statusscreen/Weather.go index f763dbf..bb4ea52 100644 --- a/src/statusscreen/Weather.go +++ b/src/statusscreen/Weather.go @@ -29,7 +29,11 @@ func (weather *Weather) GetOutput() []string { parts := strings.Split(weather.lastResponse, "\n") - return parts[:len(parts)-5] + if len(parts) > 6 { + return parts[:len(parts)-5] + } + + return []string{} } func (weather *Weather) getWeather() (string, error) {