diff options
-rw-r--r-- | weather.go | 11 |
1 files changed, 7 insertions, 4 deletions
@@ -4,6 +4,8 @@ package main // TODO: decode weather type number // TODO: split out met office specific stuff to separate module // TODO: add other weather providers +// TODO: add -v verbose flag to show all data +// TODO: add -n flag to return a certain number of days import ( "encoding/json" @@ -48,8 +50,8 @@ type WeatherParams struct { H int // Humidity P int // Pressure PP int // Precipitation Probability - UV int // Max UV Index T float64 // Temperature + UV int // Max UV Index V int // Visibility WD string // Wind Direction WG float64 // Wind Gust @@ -80,11 +82,12 @@ func main() { log.Fatal(err) } - for _, d := range r.BestFcst.Forecast.Location.Days { + for i := len(r.BestFcst.Forecast.Location.Days) - 1; i >= 0; i-- { + d := r.BestFcst.Forecast.Location.Days[i] fmt.Printf("-----------------------------\n") fmt.Printf("%s\n", d.Date) - prettyWeather("Day ", d.DayValues.WeatherParameters) - prettyWeather("Night ", d.NightValues.WeatherParameters) + prettyWeather(" Day ", d.DayValues.WeatherParameters) + prettyWeather(" Night ", d.NightValues.WeatherParameters) for _, t := range d.TimeSteps.TimeStep { prettyWeather(t.Time, t.WeatherParameters) |