Documentation ¶
Overview ¶
Package types contains all the types associated to the goweather library : weather conditions, cities... Structures are not meant to be initialized by the user itself but only by the writer when editing the library.
Index ¶
Constants ¶
const APIURL = "https://api.openweathermap.org"
APIURL contains the address of the OpenWeatherMap API
Variables ¶
var ConditionEmojis = map[string]rune{
"01d": '☀',
"02d": '⛅',
"03d": '☁',
"04d": '☁',
"09d": '🌧',
"10d": '🌦',
"11d": '🌩',
"13d": '🌨',
"50d": '🌫',
}
ConditionEmojis contains OpenWeatherMap condition codes translated in emojis
var Endpoints = map[string]string{ "current": APIURL + "/data/2.5/weather", "forecast": APIURL + "/data/2.5/forecast", }
Endpoints contains available endpoints through the API
var Locales = []string{"ar", "bg", "ca", "cz", "de", "el", "fa", "fi", "fr", "gl", "hr", "hu",
"it", "ja", "kr", "la", "lt", "mk", "nl", "pl", "pt", "ro", "ru", "se", "sk", "sl", "es", "tr",
"ua", "vi", "zh_cn", "zh_tw", "en"}
Locales contains accepted locales in the API
var Units = []string{"default", "metric", "imperial"}
Units contains accepted units in the API
Functions ¶
This section is empty.
Types ¶
type City ¶
type City struct { // The name of the city, e.g "Lyon" Name string // Country code of the city, e.g "FR" Country string // The timestamp at which the sun rises Sunrise float64 // The timestamp at which the sun sets Sunset float64 // Coordinates of the city Coordinates Coordinates }
City represents a real city and its data
type Coordinates ¶
Coordinates represents geographic coordinates of a specific location
type Current ¶
type Current struct { // The city where the weather applies City City // The actual weather conditions at the moment Conditions WeatherConditions }
Current represents current weather data
func (*Current) UnmarshalJSON ¶
UnmarshalJSON parses data returned from the API into the structure
type Forecast ¶
type Forecast struct { // The city where the weather applies City City // A list of all the weather conditions that will apply in the near future Conditions []WeatherConditions }
Forecast represents weather forecast
func (*Forecast) UnmarshalJSON ¶
UnmarshalJSON parses data returned from the API into the structure
type WeatherConditions ¶
type WeatherConditions struct { // Timestamp at which the conditions occur Timestamp float64 // Group of the conditions (Rain, snow, clouds...) Name string // Full description of the conditions Description string // URL to the PNG icon IconURL string // Emoji associated to the condition Emoji rune // Temperature at the location Temperature float64 // Minimum temperature that can be felt MinimumTemperature float64 // Maximum temperature that can be felt MaximumTemperature float64 // Pressure at the location Pressure float64 // Humidity at the location (percentage) Humidity float64 // CLouds level (percentage) Clouds float64 // Wind speed WindSpeed float64 }
WeatherConditions represents weather conditions at a specific moment
func ParseWeatherConditions ¶
func ParseWeatherConditions(data map[string]interface{}) WeatherConditions
ParseWeatherConditions returns weather conditions parsed in a structure