Socket
Socket
Sign inDemoInstall

github.com/trende-jp/go-darksky

Package Overview
Dependencies
3
Alerts
File Explorer

Install Socket

Detect and block malicious and high-risk dependencies

Install

    github.com/trende-jp/go-darksky

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


Version published

Readme

Source

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

FAQs

Last updated on 24 Jul 2019

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc