code refactoring

This commit is contained in:
2025-06-18 11:13:47 +02:00
parent a87b6a0c06
commit e46ce3e2b2
5 changed files with 45 additions and 60 deletions

View File

@@ -31,17 +31,15 @@ func GetMetrics(city *types.City, apiKey string) (types.Metrics, error) {
}
defer res.Body.Close()
// Structures representing the JSON response
type CurrentRes struct {
Humidity int `json:"humidity"`
Pressure int `json:"pressure"`
DewPoint float64 `json:"dew_point"`
UvIndex float64 `json:"uvi"`
Visibility float64 `json:"visibility"`
}
// Structure representing the JSON response
type MetricsRes struct {
Current CurrentRes `json:"current"`
Current struct {
Humidity int `json:"humidity"`
Pressure int `json:"pressure"`
DewPoint float64 `json:"dew_point"`
UvIndex float64 `json:"uvi"`
Visibility float64 `json:"visibility"`
} `json:"current"`
}
var metricRes MetricsRes