summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--weather.go6
1 files changed, 4 insertions, 2 deletions
diff --git a/weather.go b/weather.go
index f14ec38..4eb5c13 100644
--- a/weather.go
+++ b/weather.go
@@ -73,12 +73,14 @@ func main() {
id = defid
}
- client := &http.Client{Transport: &http.Transport{}}
- resp, err := client.Get("https://www.metoffice.gov.uk/public/data/PWSCache/BestForecast/Forecast/" + id + ".json?concise=true")
+ resp, err := http.Get("https://www.metoffice.gov.uk/public/data/PWSCache/BestForecast/Forecast/" + id + ".json?concise=true")
if err != nil {
log.Fatal(err)
}
defer resp.Body.Close()
+ if resp.StatusCode != http.StatusOK {
+ log.Fatalf("HTTP status code: %d\n", resp.StatusCode)
+ }
b, err := ioutil.ReadAll(resp.Body)
err = json.Unmarshal(b, &r)
if err != nil {