aemet/main.go

27 lines
496 B
Go
Raw Normal View History

2024-04-29 08:58:30 +02:00
package main
import (
"fmt"
"io"
"log"
"net/http"
)
func main() {
resp, err := http.Get("https://www.aemet.es/xml/municipios/localidad_46250.xml")
if err != nil {
log.Fatalf("Error occurred pulling data: %v\n", err)
}
defer resp.Body.Close()
if resp.StatusCode != http.StatusOK {
log.Fatalf("Error occurred accessing website: %v\n", err)
}
data, err := io.ReadAll(resp.Body)
if err != nil {
log.Fatalf("Error occurred reading data: %v\n", err)
}
fmt.Print(string(data))
}