Giter Site home page Giter Site logo

darksky's Introduction

forecast

Dark Sky API wrapper in Go (Golang)

Documentation: https://darksky.net/dev/docs

Example usage:

package main

import (
    "fmt"
    forecast "github.com/mlbright/darksky/v2"
    "io/ioutil"
    "log"
    "strings"
)

func main() {

    keybytes, err := ioutil.ReadFile("api_key.txt")
    if err != nil {
        log.Fatal(err)
    }
    key := string(keybytes)
    key = strings.TrimSpace(key)

    lat := "43.6595"
    long := "-79.3433"

    f, err := forecast.Get(key, lat, long, "now", forecast.CA, forecast.English)
    if err != nil {
        log.Fatal(err)
    }
    fmt.Printf("%s: %s\n", f.Timezone, f.Currently.Summary)
    fmt.Printf("humidity: %.2f\n", f.Currently.Humidity)
    fmt.Printf("temperature: %.2f Celsius\n", f.Currently.Temperature)
    fmt.Printf("wind speed: %.2f\n", f.Currently.WindSpeed)

}

darksky's People

Contributors

bcobb avatar billykwooten avatar danesparza avatar elcuervo avatar fetus-hina avatar ghedamat avatar intabulas avatar jmourelos avatar jozsefsallai avatar justincampbell avatar meisterluk avatar mlbright avatar pinetum avatar sbdchd avatar tdubrownik avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

darksky's Issues

Add support for UV data

Darksky now supports the reporting of the UV Index and its daily peak time.
Could we add these two fields to the DataPoint struct?

UVIndex int64 `json:"uvIndex,omitempty"`
UVIndexTime int64 `json:"uvIndexTime,omitempty"`

Let me know if you need a formal diff.

nearestStormDistance should be float64

Hello! I'm one of the developers of the Dark Sky API. We were interacting with a client and there was some confusion over the proper typing of some of the return values from our API!

In particular, the return value of nearestStormDistance should be a float64: while we currently only return integer values for this property, we make no guarantee that this will always be the case, and so clients should treat this property as if may have a fractional component.

https://github.com/mlbright/darksky/blob/master/v2/forecast.go#L51

I did a quick double-check and all of the other properties appear to have correct typing rules. (Everything is a float64, except for times (which are integers) and precipType (which is a string).)

License

Hi there and nice work! Just wondering what kind of license this is under? Could you add one?

"Never make any assumptions about the presence of data"

I recommend adding "omitempty" to all struct field tag values. Why? Because the documentation specifies:

Never make any assumptions about the presence of data or lengths of arrays. For example, a lack of data in our data sources may cause data to be missing, and Daylight Savings Time may cause a day to consist of 23 or 25 hours (instead of the usual 24). Always check for the presence of data before trying to use it.

Change all time values to int64

They are all unixtime values, so a float simply adds complexity to any code which needs to deal with it. Alternatively, a time.Time would work here.

This is in DataPoint and alert.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.