windy

package module
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2025 License: MIT Imports: 10 Imported by: 0

README

windyv1

The windyv1 is a simple http client application to retrieve the real-time weather from windyapi.com website for a given airport code's latitude, longitude and apikey. The real-time response will be in the Json format. It is up to the end user as how they want to process the response. The data could be saved for additional processing or simply could be added in the database for other applications to process the data.

An example of invoking windy application is shown below. resp, err := windy.GetWeather(53.1900, -112.2500, "valid api key")

Here's how to install it:

go install github.com/golangtrainingapp/windyv2@latest

Documentation

Overview

The windy package is a simple http server package that makes request to windyapi.com and retrieves the real-time weather for a given latitude and longitude. When the client consumes this package they need to have latitude, longitude and apikey

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildRequest

func BuildRequest(latitude, longitude float64, apiKey string, methodType string, endPoint string) (*http.Request, error)

The BuildRequest function internally invokes buildAPIRequest method for building the POST request

func ParseWindyResponse

func ParseWindyResponse(resp *http.Response, err error) ([]byte, error)

The ParseWindyResponse function parses the response from WindyAPI.com. If the parsing is successful it returns the response else it returns the error

Types

type Config

type Config struct {
	ServerInfo struct {
		Endpoint string `json:"endpoint"`
		ApiKey   string `json:"apikey"`
	}
}

func LoadConfig

func LoadConfig(yamlFile string) (*Config, error)

type Windy_Realtime_Report

type Windy_Realtime_Report struct {
	Ts    []int64 `json:"ts"`
	Units struct {
		TempSurface             string `json:"temp-surface"`
		Temp1000H               string `json:"temp-1000h"`
		Temp800H                string `json:"temp-800h"`
		Temp400H                string `json:"temp-400h"`
		Temp200H                string `json:"temp-200h"`
		DewpointSurface         string `json:"dewpoint-surface"`
		Dewpoint1000H           string `json:"dewpoint-1000h"`
		Dewpoint800H            string `json:"dewpoint-800h"`
		Dewpoint400H            string `json:"dewpoint-400h"`
		Dewpoint200H            string `json:"dewpoint-200h"`
		Past3HprecipSurface     string `json:"past3hprecip-surface"`
		Past3HconvprecipSurface string `json:"past3hconvprecip-surface"`
		Past3HsnowprecipSurface string `json:"past3hsnowprecip-surface"`
		WindUSurface            string `json:"wind_u-surface"`
		WindU1000H              string `json:"wind_u-1000h"`
		WindU800H               string `json:"wind_u-800h"`
		WindU400H               string `json:"wind_u-400h"`
		WindU200H               string `json:"wind_u-200h"`
		WindVSurface            string `json:"wind_v-surface"`
		WindV1000H              string `json:"wind_v-1000h"`
		WindV800H               string `json:"wind_v-800h"`
		WindV400H               string `json:"wind_v-400h"`
		WindV200H               string `json:"wind_v-200h"`
		GustSurface             string `json:"gust-surface"`
		CapeSurface             string `json:"cape-surface"`
		PtypeSurface            any    `json:"ptype-surface"`
		LcloudsSurface          string `json:"lclouds-surface"`
		McloudsSurface          string `json:"mclouds-surface"`
		HcloudsSurface          string `json:"hclouds-surface"`
		RhSurface               string `json:"rh-surface"`
		Rh1000H                 string `json:"rh-1000h"`
		Rh800H                  string `json:"rh-800h"`
		Rh400H                  string `json:"rh-400h"`
		Rh200H                  string `json:"rh-200h"`
		GhSurface               string `json:"gh-surface"`
		Gh1000H                 string `json:"gh-1000h"`
		Gh800H                  string `json:"gh-800h"`
		Gh400H                  string `json:"gh-400h"`
		Gh200H                  string `json:"gh-200h"`
		PressureSurface         string `json:"pressure-surface"`
	} `json:"units"`
	TempSurface             []float64 `json:"temp-surface"`
	Temp1000H               []float64 `json:"temp-1000h"`
	Temp800H                []float64 `json:"temp-800h"`
	Temp400H                []float64 `json:"temp-400h"`
	Temp200H                []float64 `json:"temp-200h"`
	DewpointSurface         []float64 `json:"dewpoint-surface"`
	Dewpoint1000H           []float64 `json:"dewpoint-1000h"`
	Dewpoint800H            []float64 `json:"dewpoint-800h"`
	Dewpoint400H            []float64 `json:"dewpoint-400h"`
	Dewpoint200H            []float64 `json:"dewpoint-200h"`
	Past3HprecipSurface     []float64 `json:"past3hprecip-surface"`
	Past3HconvprecipSurface []float64 `json:"past3hconvprecip-surface"`
	Past3HsnowprecipSurface []float64 `json:"past3hsnowprecip-surface"`
	WindUSurface            []float64 `json:"wind_u-surface"`
	WindU1000H              []float64 `json:"wind_u-1000h"`
	WindU800H               []float64 `json:"wind_u-800h"`
	WindU400H               []float64 `json:"wind_u-400h"`
	WindU200H               []float64 `json:"wind_u-200h"`
	WindVSurface            []float64 `json:"wind_v-surface"`
	WindV1000H              []float64 `json:"wind_v-1000h"`
	WindV800H               []float64 `json:"wind_v-800h"`
	WindV400H               []float64 `json:"wind_v-400h"`
	WindV200H               []float64 `json:"wind_v-200h"`
	GustSurface             []float64 `json:"gust-surface"`
	CapeSurface             []float64 `json:"cape-surface"`
	PtypeSurface            []int     `json:"ptype-surface"`
	LcloudsSurface          []float64 `json:"lclouds-surface"`
	McloudsSurface          []float64 `json:"mclouds-surface"`
	HcloudsSurface          []float64 `json:"hclouds-surface"`
	RhSurface               []float64 `json:"rh-surface"`
	Rh1000H                 []float64 `json:"rh-1000h"`
	Rh800H                  []float64 `json:"rh-800h"`
	Rh400H                  []float64 `json:"rh-400h"`
	Rh200H                  []float64 `json:"rh-200h"`
	GhSurface               []float64 `json:"gh-surface"`
	Gh1000H                 []float64 `json:"gh-1000h"`
	Gh800H                  []float64 `json:"gh-800h"`
	Gh400H                  []float64 `json:"gh-400h"`
	Gh200H                  []float64 `json:"gh-200h"`
	PressureSurface         []float64 `json:"pressure-surface"`
	Warning                 string    `json:"warning"`
}

Windy Model

func GetWeather

func GetWeather(latitude, longitude float64, apiKey string) (Windy_Realtime_Report, error)

The GetWeather function is responsible for retrieving the real-time weather response for a given latitude and longitude from WindyAPI.com. The apiKey is also necessary as the validation is performed by WindyAPI.com. An POST request is sent to WindyAPI.com to retrieve the real-time weather results

func UnMarshalResponseToWindyObject

func UnMarshalResponseToWindyObject(respBytes []byte) (Windy_Realtime_Report, error)

The UnMarshalResponseToWindyObject function unmarshal's the WindyAPI.com response to a WindyAPI structure. If the operation is successful it returns the structure else it returns error

Directories

Path Synopsis
cmd
windy command

Jump to

Keyboard shortcuts

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