(no title)
blindseer | 2 years ago
Like take a look at this pattern:
err := db.Get(&latLong, "SELECT lat, long FROM cities WHERE name = $1", name)
if err == nil {
return latLong, nil
}
latLong, err = fetchLatLong(name)
if err != nil {
return nil, err
}
err = insertCity(db, name, *latLong)
if err != nil {
return nil, err
}
Is it really necessary to have the error handling explicit in this case? Go through any of your go code. I find this kind of error handling is 90% of the error handling I write.
mariusor|2 years ago
If you just append if err != nil blocks everywhere without reasoning about the context you're probably doing it wrong.
badrequest|2 years ago
mighmi|2 years ago
Handle(err)