3 ms·
Panic is _semantically_ the same as throw. That Go culture treats panic like evil voodoo doesn't change how the language construct works.
by quotemstr 9y ago
Panic is _semantically_ the same as throw. That Go culture treats panic like evil voodoo doesn't change how the language construct works.
- PopsiclePete 9y agoNobody in Go culture treats it as "evil voodoo" that I'm aware of. There are clear guide-lines. User passes in a path to a file that doesn't exist and you attempt to open it? Return an error. That's not "exceptional" or "programmer error" - it's just normal "shit happens". You have an array-like structure with 10 elements and your function that modifies it gets passed in index 13? That's probably a bug or programmer error, not "user" error - so panic. Go documentation is very clear on the difference between the two, actually. I've never been confused.