diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..1b489d7 --- /dev/null +++ b/go.mod @@ -0,0 +1,3 @@ +module aemet + +go 1.22.2 diff --git a/main.go b/main.go new file mode 100644 index 0000000..854a761 --- /dev/null +++ b/main.go @@ -0,0 +1,26 @@ +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)) +}