openWeatherMap

package
v0.0.0-...-2a023ee Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CurrentWeatherData

type CurrentWeatherData struct {
	APIkey string
}

func (*CurrentWeatherData) GetByCityAndCountryCode

func (c *CurrentWeatherData) GetByCityAndCountryCode(city, countryCode string) (weather *Weather, err error)

GetByCityAndCountryCode returns the current weather data by passing a city name and an ISO country code. It returns weather information or a detailed error For example, to query about Madrid, Spain you do:

currentWeather.GetByCityAndCountryCode("Madrid", "ES)

func (*CurrentWeatherData) GetByGeoCoordinates

func (c *CurrentWeatherData) GetByGeoCoordinates(lat, lon float32) (weather *Weather, err error)

GetByGeoCoordinates returns the current weather data by passing a geographical coordinates (latitude and longitude) in decimal notation. It returns weather information or a detailed error. For example, to query about Madrid, Spain you do:

currentWeather.GetByGeoCoordinates(-3, 40)

type CurrentWeatherDataRetriever

type CurrentWeatherDataRetriever interface {
	GetByGeoCoordinates(lat, lon float32) (*Weather, error)
	GetByCityAndCountryCode(city, countryCode string) (*Weather, error)
}

type Weather

type Weather struct {
	Coord struct {
		Lon float32 `json:"lon"`
		Lat float32 `json:"lat"`
	} `json:"coord"`
	Weather []struct {
		Id          int    `json:"id"`
		Main        string `json:"main"`
		Description string `json:"description"`
		Icon        string `json:"icon"`
	} `json:"weather"`
	Base string `json:"base"`
	Main struct {
		Temp     float32 `json:"temp"`
		Pressure float32 `json:"pressure"`
		Humidity float32 `json:"humidity"`
		TempMin  float32 `json:"temp_min"`
		TempMax  float32 `json:"temp_max"`
	} `json:"main"`
	Wind struct {
		Speed float32 `json:"speed"`
		Deg   float32 `json:"deg"`
	} `json:"wind"`
	Clouds struct {
		All int `json:"all"`
	} `json:"clouds"`
	Rain struct {
		ThreeHours float32 `json:"3h"`
	} `json:"rain"`
	Dt  uint32 `json:"dt"`
	Sys struct {
		Type    int     `json:"type"`
		ID      int     `json:"id"`
		Message float32 `json:"message"`
		Country string  `json:"country"`
		Sunrise int     `json:"sunrise"`
		Sunset  int     `json:"sunset"`
	} `json:"sys"`
	ID   int    `json:"id"`
	Name string `json:"name"`
	Cod  int    `json:"cod"`
}

Jump to

Keyboard shortcuts

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