Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

github.com/vascocosta/owm

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/vascocosta/owm

  • v0.0.0-20150101012210-5dc4adf0c67c
  • Source
  • Go
  • Socket score

Version published
Created
Source

owm

Package owm implements a wrapper for the Open Weather Map API.

Read more about the original API here: http://openweathermap.org/api.

Installation

go get github.com/vascocosta/owm

Documentation

godoc github.com/vascocosta/owm

Read it online here: http://godoc.org/github.com/vascocosta/owm.

Examples

package main

import (
	"fmt"
	"github.com/vascocosta/owm"
	"log"
)

func main() {
	// Create a new Client given an API key.
	c := owm.NewClient("YOUR_OPEN_WEATHER_MAP_API_KEY")
	// Decode the current weather of a location given the city name and
	// units. WeatherByName returns a Weather.
	w, err := c.WeatherByName("Lisbon", "metric")
	// If there is an error, print it and terminate the program.
	if err != nil {
		log.Fatal(err)
	}
	// Print a string representation of w using the Stringer interface.
	fmt.Println(&w)
}
package main

import (
	"fmt"
	"github.com/vascocosta/owm"
	"log"
)

func main() {
	// Create a new Client given an API key.
	c := owm.NewClient("YOUR_OPEN_WEATHER_MAP_API_KEY")
	// Decode the current weather of a location given the city id and
	// units. WeatherById returns a Weather.
	w, err := c.WeatherById(2267057, "metric")
	// If there is an error, print it and terminate the program.
	if err != nil {
		log.Fatal(err)
	}
	// Print a string representation of w using the Stringer interface.
	fmt.Println(&w)
}
package main

import (
	"fmt"
	"github.com/vascocosta/owm"
	"log"
)

func main() {
	// Create a new Client given an API key.
	c := owm.NewClient("YOUR_OPEN_WEATHER_MAP_API_KEY")
	// Decode the current weather of a location given the city coordinates
	// and units. WeatherByCoord returns a Weather.
	w, err := c.WeatherByCoord(38.72, -9.13, "metric")
	// If there is an error, print it and terminate the program.
	if err != nil {
		log.Fatal(err)
	}
	// Print a string representation of w using the Stringer interface.
	fmt.Println(&w)
}
package main

import (
	"fmt"
	"github.com/vascocosta/owm"
	"log"
)

func main() {
	// Create a new Client given an API key.
	c := owm.NewClient("YOUR_OPEN_WEATHER_MAP_API_KEY")
	// Decode the current weather of multiple locations given the zone
	// coordinates, map zoom and units. WeatherByZone returns a []Weather.
	w, err := c.WeatherByZone(12, 32, 15, 37, 10, "metric")
	// If there is an error, print it and terminate the program.
	if err != nil {
		log.Fatal(err)
	}
	// Print a string representation of w using the Stringer interface.
	for i := range w {
		fmt.Println(&w[i])
	}
}
package main

import (
	"fmt"
	"github.com/vascocosta/owm"
	"log"
)

func main() {
	// Create a new Client given an API key.
	c := owm.NewClient("YOUR_OPEN_WEATHER_MAP_API_KEY")
	// Decode the current weather of multiple locations given the center
	// coordinates, radius and units. WeatherByRadius returns a []Weather.
	w, err := c.WeatherByRadius(38.72, -9.13, 10, "metric")
	// If there is an error, print it and terminate the program.
	if err != nil {
		log.Fatal(err)
	}
	// Print a string representation of w using the Stringer interface.
	for i := range w {
		fmt.Println(&w[i])
	}
}
package main

import (
	"fmt"
	"github.com/vascocosta/owm"
	"log"
)

func main() {
	// Create a new Client given an API key.
	c := owm.NewClient("YOUR_OPEN_WEATHER_MAP_API_KEY")
	// Decode the current weather of multiple locations given a slice of
	// city ids and units. WeatherByIds returns a []Weather.
	w, err := c.WeatherByIds([]int{2267057, 2735943, 2268339}, "metric")
	// If there is an error, print it and terminate the program.
	if err != nil {
		log.Fatal(err)
	}
	// Print a string representation of w using the Stringer interface.
	for i := range w {
		fmt.Println(&w[i])
	}
}
package main

import (
	"fmt"
	"github.com/vascocosta/owm"
	"log"
)

func main() {
	// Create a new Client given an API key.
	c := owm.NewClient("YOUR_OPEN_WEATHER_MAP_API_KEY")
	// Decode the current forecast of a location given the city name, days
	// and units. ForecastByName returns a Forecast.
	f, err := c.ForecastByName("Lisbon", 4, "metric")
	// If there is an error, print it and terminate the program.
	if err != nil {
		log.Fatal(err)
	}
	// Print a string representation of f using the Stringer interface.
	fmt.Println(&f)
}
package main

import (
	"fmt"
	"github.com/vascocosta/owm"
	"log"
)

func main() {
	// Create a new Client given an API key.
	c := owm.NewClient("YOUR_OPEN_WEATHER_MAP_API_KEY")
	// Decode the current forecast of a location given the city id, days
	// and units. ForecastById returns a Forecast.
	f, err := c.ForecastById(2267057, 8, "metric")
	// If there is an error, print it and terminate the program.
	if err != nil {
		log.Fatal(err)
	}
	// Print a string representation of f using the Stringer interface.
	fmt.Println(&f)
}
package main

import (
	"fmt"
	"github.com/vascocosta/owm"
	"log"
)

func main() {
	// Create a new Client given an API key.
	c := owm.NewClient("YOUR_OPEN_WEATHER_MAP_API_KEY")
	// Decode the current forecast of a location given the city coordinates,
	// days and units. ForecastByCoord returns a Forecast.
	f, err := c.ForecastByCoord(38.72, -9.13, 16, "metric")
	// If there is an error, print it and terminate the program.
	if err != nil {
		log.Fatal(err)
	}
	// Print a string representation of f using the Stringer interface.
	fmt.Println(&f)
}

FAQs

Package last updated on 01 Jan 2015

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc