3 ms·
You should be checking errors immediately after they are returned. Once you've checked it, re-use the variable: x, err := f(a) if err != nil { // probably
by jff 14y ago
You should be checking errors immediately after they are returned. Once you've checked it, re-use the variable:
x, err := f(a)
if err != nil { // probably time to return from the func }
y, err := g(x) // we have at least 1 new var, so := still works
if err != nil { // handle }
x, err = h(y) // since we're re-using both x and err, just use =
I've never appended a number to "err".