windDirection to windDir in ObservationHour
rename json windDirection parse to windDir
remove omitempty
A go library for reading weather data from Metservice. Unfortunately this API isn't documented and probably not even intended for public usage. Reading through the godocs documentation will give you an idea of the values the API will return, but the best way to figure it out is just messing with it a bit.
For a longer more practical example see metweather a cli app built with this library.
Discussion and patches can be found here.
import (
"context"
"fmt"
"git.sr.ht/~kota/metservice-go"
)
func main() {
client := NewClient()
ctx := context.Background()
forecast, _, err := client.GetForecast(ctx, "Dunedin")
if err != nil {
fmt.Println(err)
return
}
fmt.Println(*forecast.LocationIPS)
for _, day := range forecast.Days {
fmt.Printf("%v\nforecast: %v\nmax: %vC\nmin: %vC\n\n",
*day.Date,
*day.ForecastWord,
*day.Max,
*day.Min)
}
}