Added basic validation for location input

This commit is contained in:
Andrew Scott 2022-07-13 17:04:33 -04:00
parent 9296d7a629
commit 403cb21b51
Signed by: a
GPG key ID: 3EB62D0BBB8DB381

View file

@ -37,8 +37,20 @@ func advancedMenu(app *application) {
}
fmt.Printf("\nChanged units from %s to %s...\n\n", current, app.Config.Units)
} else if option == "2" {
getPreciseLocation(app)
getCurrent(app)
var validLoc bool
for !validLoc {
getPreciseLocation(app)
getCurrent(app)
if app.Forecast.Main.Temp != 0.00 {
validLoc = true
} else {
fmt.Println("I couldn't get any information for that location.")
fmt.Println("Are you sure the coordinates are valid?")
}
}
printWeather(app)
}
}