summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick White <git@njw.name>2020-02-10 12:06:45 +0000
committerNick White <git@njw.name>2020-02-10 12:06:45 +0000
commit0e2d1c42c9b56e2676603aefe2dafdefa32b3d3a (patch)
tree583b69359e4f2fc8c5188e1619b9cd202a6cee91
parent80b9bfa2c71ea971db2e71fab1641cf7e140336d (diff)
downloadweather-0e2d1c42c9b56e2676603aefe2dafdefa32b3d3a.tar.bz2
weather-0e2d1c42c9b56e2676603aefe2dafdefa32b3d3a.zip
Show weather code if no description is known
-rw-r--r--weather.go6
1 files changed, 5 insertions, 1 deletions
diff --git a/weather.go b/weather.go
index cb6128d..237b707 100644
--- a/weather.go
+++ b/weather.go
@@ -236,7 +236,11 @@ func main() {
for _, w := range weather {
fmt.Printf("%s %s ", w.date, w.time)
- fmt.Printf("%18s, Temp: %4.1f°C, ", TypeDescription[w.weathertype], w.temperature)
+ desc := TypeDescription[w.weathertype]
+ if desc == "" {
+ desc = fmt.Sprintf("%d", w.weathertype)
+ }
+ fmt.Printf("%18s, Temp: %4.1f°C, ", desc, w.temperature)
fmt.Printf("Rain: %2d%%, Wind: %4.1fmph\n", w.precipitation, w.windspeed)
if *verbose {
fmt.Printf(" %+v\n", w)