diff --git a/cmd/location.go b/cmd/location.go index 663b24c..4443b10 100644 --- a/cmd/location.go +++ b/cmd/location.go @@ -24,12 +24,12 @@ func getLocation(app *Application) { body, err := ioutil.ReadAll(res.Body) if err != nil { - log.Println(err) + log.Printf("Error reading location from server: %v\n", err) } err = json.Unmarshal(body, &app.Config) if err != nil { - log.Println(err) + log.Printf("Error reading JSON from server: %v", err) } loc := strings.Split(app.Config.Location, ",") diff --git a/cmd/main.go b/cmd/main.go index 0ee26b3..91d4a70 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -50,12 +50,12 @@ type Date struct { } type Config struct { - Units string `json:"units"` + Units string Location string `json:"loc"` Longitude string `json:"lat"` Latitude string `json:"lon"` Date Date - ApiKey string `json:"appid"` + ApiKey string } type Application struct { diff --git a/cmd/weather.go b/cmd/weather.go index 4b72565..1b77383 100644 --- a/cmd/weather.go +++ b/cmd/weather.go @@ -15,22 +15,22 @@ func getCurrent(app *Application) { lon := "&lon=" + app.Config.Longitude units := "&units=" + app.Config.Units key := "&appid=" + app.Config.ApiKey - url := "https://pro.openweathermap.org/data/2.5/weather?" + lat + lon + units + key + url := "https://api.openweathermap.org/data/2.5/weather?" + lat + lon + units + key res, err := http.Get(url) if err != nil { - log.Println(err) + log.Printf("Error getting current forecast: %v", err) } defer res.Body.Close() fmt.Println(res.Body) body, err := ioutil.ReadAll(res.Body) if err != nil { - log.Println(err) + log.Printf("Error reading response from server: %v\n", err) } err = json.Unmarshal(body, &app.Forecast) if err != nil { - log.Println(err) + log.Printf("Error reading JSON from server: %v\n", err) } } @@ -41,7 +41,7 @@ func getCurrentByLoc(app *Application) { zip := app.Config.Location units := "&units=" + app.Config.Units key := "&appid=" + app.Config.ApiKey - url := "https://pro.openweathermap.org/data/2.5/weather?q=" + zip + units + key + url := "https://api.openweathermap.org/data/2.5/weather?q=" + zip + units + key res, err := http.Get(url) if err != nil {