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() {
c := owm.NewClient("YOUR_OPEN_WEATHER_MAP_API_KEY")
w, err := c.WeatherByName("Lisbon", "metric")
if err != nil {
log.Fatal(err)
}
fmt.Println(&w)
}
package main
import (
"fmt"
"github.com/vascocosta/owm"
"log"
)
func main() {
c := owm.NewClient("YOUR_OPEN_WEATHER_MAP_API_KEY")
w, err := c.WeatherById(2267057, "metric")
if err != nil {
log.Fatal(err)
}
fmt.Println(&w)
}
package main
import (
"fmt"
"github.com/vascocosta/owm"
"log"
)
func main() {
c := owm.NewClient("YOUR_OPEN_WEATHER_MAP_API_KEY")
w, err := c.WeatherByCoord(38.72, -9.13, "metric")
if err != nil {
log.Fatal(err)
}
fmt.Println(&w)
}
package main
import (
"fmt"
"github.com/vascocosta/owm"
"log"
)
func main() {
c := owm.NewClient("YOUR_OPEN_WEATHER_MAP_API_KEY")
w, err := c.WeatherByZone(12, 32, 15, 37, 10, "metric")
if err != nil {
log.Fatal(err)
}
for i := range w {
fmt.Println(&w[i])
}
}
package main
import (
"fmt"
"github.com/vascocosta/owm"
"log"
)
func main() {
c := owm.NewClient("YOUR_OPEN_WEATHER_MAP_API_KEY")
w, err := c.WeatherByRadius(38.72, -9.13, 10, "metric")
if err != nil {
log.Fatal(err)
}
for i := range w {
fmt.Println(&w[i])
}
}
package main
import (
"fmt"
"github.com/vascocosta/owm"
"log"
)
func main() {
c := owm.NewClient("YOUR_OPEN_WEATHER_MAP_API_KEY")
w, err := c.WeatherByIds([]int{2267057, 2735943, 2268339}, "metric")
if err != nil {
log.Fatal(err)
}
for i := range w {
fmt.Println(&w[i])
}
}
package main
import (
"fmt"
"github.com/vascocosta/owm"
"log"
)
func main() {
c := owm.NewClient("YOUR_OPEN_WEATHER_MAP_API_KEY")
f, err := c.ForecastByName("Lisbon", 4, "metric")
if err != nil {
log.Fatal(err)
}
fmt.Println(&f)
}
package main
import (
"fmt"
"github.com/vascocosta/owm"
"log"
)
func main() {
c := owm.NewClient("YOUR_OPEN_WEATHER_MAP_API_KEY")
f, err := c.ForecastById(2267057, 8, "metric")
if err != nil {
log.Fatal(err)
}
fmt.Println(&f)
}
package main
import (
"fmt"
"github.com/vascocosta/owm"
"log"
)
func main() {
c := owm.NewClient("YOUR_OPEN_WEATHER_MAP_API_KEY")
f, err := c.ForecastByCoord(38.72, -9.13, 16, "metric")
if err != nil {
log.Fatal(err)
}
fmt.Println(&f)
}