4 ms·
> Warnings don't exist in go build, because warnings are ignored by people. Okay, make them errors - an unused import is an error and the risk is orders of mag
by acdha 8y ago
> Warnings don't exist in go build, because warnings are ignored by people.
Okay, make them errors - an unused import is an error and the risk is orders of magnitude lower.
> There are legitimate use cases of swallowing error return values†, and if you throw warnings intros cases, then you can't tell the difference between a legit warning and a legit use case that shouldn't warn.
Nobody is saying there aren’t cases where you can legitimately ignore them. My position is just that it should require intent rather than being the default: you should have to access any error type at least once after assignment, even if it’s just to intentionally ignore an expected error (which is also important for confirming that the error you’re ignoring is the one you expected and not something else).
Regarding examples, yes, there’s a balance of not overcrowding examples but people retain early lessons for long periods of time. Since almost all non-trivial Go programs work with things like files and networks, it should be more prominent because the language repeats the C style approach of leaving error handling up to programmer diligence and that means you need to develop the habit from the beginning because the language doesn’t have any other protections.