19 ms·
As I have said before, the fact that it is used, doesn't validate the usage. Yes, Go has recover. Yes, the stdlib uses it here and there. Does any of that chan
by usrbinbash 2y ago
As I have said before, the fact that it is used, doesn't validate the usage. Yes, Go has recover. Yes, the stdlib uses it here and there.
Does any of that change the semantics of what a panic means, and how applications should therefore react? No. Does it make panics the equivalent of exceptions in Python semantically? Also no.
And this logic isn't limited to Go. Guess what, there are python libraries that use Exceptions for control flow. It certainly works. Does that validate using Exceptions as control flow elements? No, of course not. Why? Because that's not what an exception exists for semantically.
Panic-Recover cycles in go codebases are an antipattern, and unless I see an official statement by the people who make Go (who also write "Effective Go" btw.) saying otherwise, those are the semantics of the language.