2 ms·
If want (and if it makes sense) you can use panics as a control flow mechanism to quickly bubble up errors inside your implementations. See an example in the s
by ithkuil 8y ago
If want (and if it makes sense) you can use panics as a control flow mechanism to quickly bubble up errors inside your implementations.
See an example in the standard library itself: https://golang.org/src/encoding/json/encode.go https://golang.org/src/encoding/json/encode.go, line 295
What's frowned upon is leaking this out of your package's interface/contract.
- bb88 8y agoThen it strikes me kind of like C++ exceptions. They have them, and it's kinda supported, and there are certain things you shouldn't do with them, so everyone just uses return codes. Java/Python encourage the use of exceptions as returning error conditions, rather than return error codes.