Package darksky
implements a client for the Dark Sky weather forecasting
API.
- Support for all Dark Sky API functionality.
- Idomatic Go API, including support for
context
and Go modules. - Language matching.
- Fully tested, including error conditions.
- Mock client for offline testing.
- Monitoring hooks.
func ExampleClient_Forecast() {
c := darksky.NewClient(
darksky.WithKey(os.Getenv("DARKSKY_KEY")),
)
ctx := context.Background()
forecast, err := c.Forecast(ctx, 42.3601, -71.0589, nil, &darksky.ForecastOptions{
Units: darksky.UnitsSI,
})
if err != nil {
fmt.Println(err)
return
}
// The forecast varies from day to day. Print something stable.
fmt.Println(forecast.Timezone)
// Output:
// America/New_York
}
There are several existing Dark Sky client libraries. Compared to these, no other Go library provides all of the following:
- Correct use of types for latitude and longitude:
float64
s, notstring
s. - Correct use of types for times:
time.Time
s, notstring
s. - Support for
context
. - Support for Go modules.
- Rich handling of errors, including both bad requests generic HTTP errors.
- Monitoring hooks.
Adding any of these to an exising Go Dark Sky client library would break API compatibilty, hence the new client library.
MIT