diff options
author | Nick White <git@njw.name> | 2018-04-16 15:15:44 +0100 |
---|---|---|
committer | Nick White <git@njw.name> | 2018-04-16 15:15:44 +0100 |
commit | d2613b543db5c2d9c1f48d79d47bfcf7c1388f92 (patch) | |
tree | 04f4110c6ec9ade24eb13cf882eb91da4b4c15a6 | |
parent | 063bd9c7174811580e39733385ed6e8e80ebca08 (diff) | |
download | weather-d2613b543db5c2d9c1f48d79d47bfcf7c1388f92.tar.bz2 weather-d2613b543db5c2d9c1f48d79d47bfcf7c1388f92.zip |
Use description of weather rather than just the type number
-rw-r--r-- | weather.go | 14 |
1 files changed, 12 insertions, 2 deletions
@@ -1,10 +1,10 @@ package main +// BUG: need to allow choice of met-office source (-b 0 doesn't work how i thought it would) // TODO: allow free-text lookups of place names, rather than ids // TODO: convert metoffice windspeed to mph // TODO: split output into days // TODO: add -n flag to only output a certain number of days -// TODO: convert weather type number into a human-friendly string // TODO: human friendly dates import ( @@ -100,6 +100,16 @@ type WeatherParams struct { WT int // Weather Type } +// TODO: complete this mapping +var TypeDescription = map[int]string{ + 0: "Clear Sky", + 1: "Sunny", + 2: "Partly Cloudy", + 3: "Sunny Intervals", + 7: "Light Cloud", + 12: "Light Rain", +} + // Our prefered struct type Weather struct { date string @@ -217,7 +227,7 @@ func main() { for _, w := range weather { fmt.Printf("%s %s ", w.date, w.time) - fmt.Printf("Type: %2d, Temp: %4.1f°C, ", w.weathertype, w.temperature) + fmt.Printf("%15s, Temp: %4.1f°C, ", TypeDescription[w.weathertype], w.temperature) fmt.Printf("Rain: %2d%%, Wind: %4.1fmph\n", w.precipitation, w.windspeed) if *verbose { fmt.Printf(" %+v\n", w) |