openweather

package
v0.0.0-...-dd7b5e9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 7, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	BaseURL = url.URL{Scheme: "https", Host: "api.openweathermap.org"}
)

Functions

This section is empty.

Types

type Client

type Client struct {
	APIKey string
}

func NewClient

func NewClient(apiKey string) Client

func (Client) CurrentWeatherAtLocation

func (c Client) CurrentWeatherAtLocation(ctx context.Context, unit Unit, latitude float64, longitude float64) (CurrentWeatherData, error)

type CurrentWeatherData

type CurrentWeatherData struct {
	Coordinate struct {
		Longitude float64 `json:"lon"`
		Lattitude float64 `json:"lat"`
	} `json:"coord"`
	WeatherConditions []WeatherCondition `json:"weather"`
	Base              string             `json:"base"`
	Main              struct {
		Temp      float64 `json:"temp"` // default temp is in kelvin
		FeelsLike float64 `json:"feels_like"`
		TempMin   float64 `json:"temp_min"`
		TempMax   float64 `json:"temp_max"`
		Pressure  int     `json:"pressure"`
		Humidity  int     `json:"humidity"`
	} `json:"main"`
	Visibility int `json:"visibility"`
	Wind       struct {
		Speed  float64 `json:"speed"`
		Degree int     `json:"deg"`
	} `json:"wind"`
	Clouds struct {
		All int `json:"all"`
	} `json:"clouds"`
	DatePastEpoch int `json:"dt"`
	Sys           struct {
		Type    int    `json:"type"`
		ID      int    `json:"id"`
		Country string `json:"country"`
		Sunrise int    `json:"sunrise"`
		Sunset  int    `json:"sunset"`
	} `json:"sys"`
	Timezone int    `json:"timezone"`
	ID       int    `json:"id"`
	Name     string `json:"name"`
	Code     int    `json:"cod"`
}

type Unit

type Unit string
const (
	UnitStandard Unit = "standard"
	UnitImperial Unit = "imperial"
	UnitMetric   Unit = "metric"
)

type WeatherCondition

type WeatherCondition struct {
	ID          int    `json:"id"`
	Name        string `json:"main"`
	Description string `json:"description"`
	Icon        string `json:"icon"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL