~kota/metservice-go

Library for reading weather data from Metservice.
windDirection to windDir in ObservationHour
rename json windDirection parse to windDir
remove omitempty

clone

read-only
https://git.sr.ht/~kota/metservice-go
read/write
git@git.sr.ht:~kota/metservice-go

You can also use your local clone with git send-email.

#metservice-go godocs.io builds.sr.ht status

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.

#Example

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)
	}
}