Skip to content

Commit

Permalink
Update function
Browse files Browse the repository at this point in the history
  • Loading branch information
zoelabbb committed Dec 10, 2023
1 parent ec1d1a0 commit 5229141
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,14 @@ func main() {
panic(err)
}

// fmt.Println(weather)

location, curerrent, hours := weather.Location, weather.Current, weather.Forecast.Forecastday[0].Hour

fmt.Printf("%s, %s: %.0fC, %s\n",
location.Name,
location.Region,
curerrent.TempC,
curerrent.Condition.Text)
fmt.Printf("Weather Forecast for %s, %s (%s): %.0fC, %s\n\n",
location.Name,
location.Region,
location.Country,
curerrent.TempC,
curerrent.Condition.Text)


for _, hour := range hours {
Expand All @@ -111,17 +110,19 @@ func main() {
}

message := fmt.Sprintf(
"Time: %s - %.0fC, %s, %.0f%% chance of rain\n",
"Time: %s \nTemp: %.0fC, %s \nChance of rain %.0f%% \n\n",
date.Format("15:04"),
hour.TempC,
hour.Condition.Text,
hour.ChanceOfRain,
)

if hour.ChanceOfRain < 40 {
color.Cyan(message)
color.Green(message)
} else if hour.ChanceOfRain >= 40 && hour.ChanceOfRain <= 70 {
color.Yellow(message)
} else {
color.Red(message)
}
}
}
}

0 comments on commit 5229141

Please sign in to comment.