Skip to content

Package darksky implements a client for the Dark Sky API. See https://darksky.net/dev.

License

Notifications You must be signed in to change notification settings

trende-jp/go-darksky

 
 

Repository files navigation

go-darksky

GoDoc Build Status Coverage Status

Package darksky implements a client for the Dark Sky weather forecasting API.

Key features

  • 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.

Example

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
}

Why a new Go Dark Sky client library?

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: float64s, not strings.
  • Correct use of types for times: time.Times, not strings.
  • 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.

License

MIT

About

Package darksky implements a client for the Dark Sky API. See https://darksky.net/dev.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Go 99.4%
  • Makefile 0.6%