weather

package
v0.0.0-...-8b2f885 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AbsoluteZero float64 = -273.15
)

Variables

This section is empty.

Functions

func DegreeToCardinalDirection

func DegreeToCardinalDirection(degrees int) string

DegreeToCardinalDirection returns string of cardinal direction given direction in degrees

func Description

func Description(weatherData Response) string

Description returns the description of the weather in title case as string

func EpochToFormattedString

func EpochToFormattedString(epochTime int64) string

func FeelsLike

func FeelsLike(weatherData Response) string

FeelsLike returns the 'feels like' temperature in Celsius with "℃" notation as string.

func GustSpeed

func GustSpeed(weatherData Response) string

GustSpeed returns wind speed in km/h with "km/h" notation as string

func Humidity

func Humidity(weatherData Response) string

Humidity returns humidity as percentage with "%" notation as string

func Location

func Location(weatherData Response) string

Location returns comma seperated string with city name and country code

func Pressure

func Pressure(weatherData Response) string

Pressure returns pressure as percentage with "%" notation as string

func Temperature

func Temperature(weatherData Response) string

Temperature returns the temperature in Celsius with "℃" notation as string.

func UpdatedDateTime

func UpdatedDateTime(weatherData Response) string

UpdatedDateTime returns formatted string of when weather was last updated

func WindSpeed

func WindSpeed(weatherData Response) string

WindSpeed returns wind speed in km/h with "km/h" notation as string

func WindSummary

func WindSummary(weatherData Response) string

WindSummary returns string of wind's speed and direction

Types

type Conditions

type Conditions struct {
	Temp      float64 `json:"temp"`       // in KELVIN
	FeelsLike float64 `json:"feels_like"` // in KELVIN
	Humidity  int     `json:"humidity"`
	Pressure  int     `json:"pressure"`
}

type Response

type Response struct {
	Weather    []Weather  `json:"weather"`
	Conditions Conditions `json:"main"`
	Wind       Wind       `json:"wind"`
	Sys        Sys        `json:"sys"`
	Name       string     `json:"name"`
	Dt         int        `json:"dt"`
}

func Data

func Data(city string, state string, country_code string, api_key string) (Response, error)

Data returns full weather data as Response with error.

type Sys

type Sys struct {
	Country string `json:"country"`
}

type Weather

type Weather struct {
	Description string `json:"description"` // Overcast Clouds
}

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