3 ms·
In Go, if a function returns only an error, you can do if err := foo(); err != nil { // handle error } However, this only works in that particular
by Cthulhu_ 3y ago
In Go, if a function returns only an error, you can do
if err := foo(); err != nil {
// handle error
}
However, this only works in that particular case, if foo() also returns a value you can no longer use this because the value (and err) are scoped to the if block.