diff options
-rw-r--r-- | weather.go | 6 |
1 files changed, 4 insertions, 2 deletions
@@ -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 { |