Security News
The Risks of Misguided Research in Supply Chain Security
Snyk's use of malicious npm packages for research raises ethical concerns, highlighting risks in public deployment, data exfiltration, and unauthorized testing.
github.com/briandowns/openweathermap
Go (golang) package for use with openweathermap.org's API.
For more detail about the library and its features, reference your local godoc once installed.
To use the OpenweatherMap API, you need to obtain an API key. Sign up here. Once you have your key, create an environment variable called OWM_API_KEY
. Start coding!
Contributions welcome!
Get the weather conditions for a given number of days.
Gain access to OpenWeatherMap icons and condition codes.
English - en, Russian - ru, Italian - it, Spanish - es (or sp), Ukrainian - uk (or ua), German - de, Portuguese - pt, Romanian - ro, Polish - pl, Finnish - fi, Dutch - nl, French - fr, Bulgarian - bg, Swedish - sv (or se), Chinese Traditional - zh_tw, Chinese Simplified - zh (or zh_cn), Turkish - tr, Croatian - hr, Catalan - ca
go get github.com/briandowns/openweathermap
There are a few full examples in the examples directory that can be referenced. 1 is a command line application and 1 is a simple web application.
package main
import (
"log"
"fmt"
"os"
// Shortening the import reference name seems to make it a bit easier
owm "github.com/briandowns/openweathermap"
)
var apiKey = os.Getenv("OWM_API_KEY")
func main() {
w, err := owm.NewCurrent("F", "ru", apiKey) // fahrenheit (imperial) with Russian output
if err != nil {
log.Fatalln(err)
}
w.CurrentByName("Phoenix")
fmt.Println(w)
}
func main() {
w, err := owm.NewCurrent("K", "EN", apiKey) // (internal - OpenWeatherMap reference for kelvin) with English output
if err != nil {
log.Fatalln(err)
}
w.CurrentByName("Phoenix,AZ")
fmt.Println(w)
}
func main() {
w, err := owm.NewForecast("5", "F", "FI", apiKey) // valid options for first parameter are "5" and "16"
if err != nil {
log.Fatalln(err)
}
w.DailyByCoordinates(
&owm.Coordinates{
Longitude: -112.07,
Latitude: 33.45,
},
5 // five days forecast
)
fmt.Println(w)
}
func main() {
w, err := owm.NewCurrent("C", "PL", apiKey)
if err != nil {
log.Fatalln(err)
}
w.CurrentByID(2172797)
fmt.Println(w)
}
func main() {
w, err := owm.NewCurrent("F", "EN", apiKey)
if err != nil {
log.Fatalln(err)
}
w.CurrentByZip(19125, "US")
fmt.Println(w)
}
func main() {
client := &http.Client{}
w, err := owm.NewCurrent("F", "EN", apiKey, owm.WithHttpClient(client))
if err != nil {
log.Fatalln(err)
}
}
func main() {
uv, err := owm.NewUV(apiKey)
if err != nil {
log.Fatalln(err)
}
coord := &owm.Coordinates{
Longitude: 53.343497,
Latitude: -6.288379,
}
if err := uv.Current(coord); err != nil {
log.Fatalln(err)
}
fmt.Println(coord)
}
func main() {
uv, err := owm.NewUV(apiKey)
if err != nil {
log.Fatalln(err)
}
coord := &owm.Coordinates{
Longitude: 54.995656,
Latitude: -7.326834,
}
end := time.Now().UTC()
start := time.Now().UTC().Add(-time.Hour * time.Duration(24))
if err := uv.Historical(coord, start, end); err != nil {
log.Fatalln(err)
}
}
func main() {
uv, err := owm.NewUV(apiKey)
if err != nil {
log.Fatalln(err)
}
coord := &owm.Coordinates{
Longitude: 53.343497,
Latitude: -6.288379,
}
if err := uv.Current(coord); err != nil {
log.Fatalln(err)
}
info, err := uv.UVInformation()
if err != nil {
log.Fatalln(err)
}
fmt.Println(info)
}
func main() {
pollution, err := owm.NewPollution(apiKey)
if err != nil {
log.Fatalln(err)
}
params := &owm.PollutionParameters{
Location: owm.Coordinates{
Latitude: 0.0,
Longitude: 10.0,
},
Datetime: "current",
}
if err := pollution.PollutionByParams(params); err != nil {
log.Fatalln(err)
}
}
func main() {
// Possibility to exclude information. For example exclude daily information []string{ExcludeDaily}
w, err := owm.NewOneCall("F", "EN", apiKey, []string{})
if err != nil {
log.Fatalln(err)
}
err = w.OneCallByCoordinates(
&Coordinates{
Longitude: -112.07,
Latitude: 33.45,
},
)
if err != nil {
t.Error(err)
}
fmt.Println(w)
}
FAQs
Unknown package
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Snyk's use of malicious npm packages for research raises ethical concerns, highlighting risks in public deployment, data exfiltration, and unauthorized testing.
Research
Security News
Socket researchers found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.
Security News
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.