From db58b6f12ee3bd80868b4edef43dd5fad08718f2 Mon Sep 17 00:00:00 2001 From: Nick White Date: Wed, 21 Mar 2018 22:45:46 +0000 Subject: Reverse output ordering so most recent is last, so closest to cursor, for less paging --- weather.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/weather.go b/weather.go index eed74d9..1c51a80 100644 --- a/weather.go +++ b/weather.go @@ -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) -- cgit v1.2.3