weather

package
v0.14.4 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2024 License: AGPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddWeatherLocation

func AddWeatherLocation(ctx context.Context, location config.WeatherLocation)

AddWeatherLocation adds a new weather location to be monitored. It takes a context.Context for cancellation and a config.WeatherLocation struct to configure the monitoring. The weather data is fetched immediately and then updated every 10 minutes until the context is cancelled. If the location is marked as default and no default exists yet, it will be set as the default location.

func DefaultLocation

func DefaultLocation() string

func SetDefaultLocation

func SetDefaultLocation(location string)

Types

type Clouds

type Clouds struct {
	All int `json:"all"`
}

type Coord

type Coord struct {
	Lon float64 `json:"lon"`
	Lat float64 `json:"lat"`
}

type Main

type Main struct {
	Temp      float64 `json:"temp"`
	FeelsLike float64 `json:"feels_like"`
	TempMin   float64 `json:"temp_min"`
	TempMax   float64 `json:"temp_max"`
	Pressure  int     `json:"pressure"`
	Humidity  int     `json:"humidity"`
	SeaLevel  int     `json:"sea_level"`
	GrndLevel int     `json:"grnd_level"`
}

type Sys

type Sys struct {
	Type    int    `json:"type"`
	ID      int    `json:"id"`
	Country string `json:"country"`
	Sunrise int    `json:"sunrise"`
	Sunset  int    `json:"sunset"`
}

type Weather

type Weather struct {
	Coord      Coord         `json:"coord"`
	Data       []WeatherData `json:"weather"`
	Base       string        `json:"base"`
	Main       Main          `json:"main"`
	Visibility int           `json:"visibility"`
	Wind       Wind          `json:"wind"`
	Clouds     Clouds        `json:"clouds"`
	Dt         int           `json:"dt"`
	Sys        Sys           `json:"sys"`
	Timezone   int           `json:"timezone"`
	ID         int           `json:"id"`
	Name       string        `json:"name"`
	Cod        int           `json:"cod"`
}

type WeatherData

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

type WeatherLocation

type WeatherLocation struct {
	Name string
	Lat  string
	Lon  string
	API  string
	Unit string
	Lang string
	Weather
}

func CurrentWeather

func CurrentWeather(name string) WeatherLocation

CurrentWeather retrieves the current weather data for a given location name. Returns a WeatherLocation struct containing the weather data, or an empty struct if not found.

type Wind

type Wind struct {
	Speed float64 `json:"speed"`
	Deg   int     `json:"deg"`
	Gust  float64 `json:"gust"`
}

Jump to

Keyboard shortcuts

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