diff options
-rw-r--r-- | nws/nws.go | 26 | ||||
-rw-r--r-- | version/version.go | 2 |
2 files changed, 6 insertions, 22 deletions
@@ -150,31 +150,15 @@ func GetForecastHourly(point *Point) (*Forecast, error) { return nil, fmt.Errorf("forecast hourly: link empty") } - // Get the forecast - resp, err := client.Get(point.Properties.ForecastHourly) - if err != nil { - return nil, fmt.Errorf("forecast hourly: get: %v", err) - } - - // Parse response body. - body, err := io.ReadAll(resp.Body) - if err != nil { - return nil, fmt.Errorf("forecast hourly: body: %v", err) - } - - // Check if the request failed. - if resp.StatusCode != 200 { - perr := new(Error) - err := json.Unmarshal(body, perr) - if err != nil { - return nil, fmt.Errorf("forecast hourly: json: %v", err) - } - return nil, fmt.Errorf("forecast: %v", perr) + // Get the hourly forecast. + body, nwsErr := get(point.Properties.ForecastHourly) + if nwsErr != nil { + return nil, fmt.Errorf("forecast hourly: %v", nwsErr) } // Unmarshal. forecast := new(Forecast) - err = json.Unmarshal(body, forecast) + err := json.Unmarshal(body, forecast) if err != nil { return nil, fmt.Errorf("forecast hourly: decode: %v", err) } diff --git a/version/version.go b/version/version.go index 8d42170..ae475bd 100644 --- a/version/version.go +++ b/version/version.go @@ -4,4 +4,4 @@ // Peach version. package version -const Version = "0.1.1" +const Version = "0.2.0.dev1" |