2 ms·
While you're correct, you can still avoid handling an error and not get any feedback from the compiler or linters by doing something like: val, err := some
by Cthulhu_ 6y ago
While you're correct, you can still avoid handling an error and not get any feedback from the compiler or linters by doing something like:
val, err := something()
val2, err := somethingElse()
if err != nil // etc
You can - and all the examples usually do - reuse and shadow an 'err' variable, and tooling won't complain as long as something is done with it at least once.
If Go wants to enforce not ignoring errors, it still has a few holes like this to fix.
- eznzt 6y agoI see now. That is indeed one of the things I hated about Go, having to reuse err (or maybe, making the mistake of reusing err) several times in a single function.