4 ms·
Panic works fine; they are basically just exceptions you can catch at a higher level. I almost exclusively use panic for my exceptions in go.
by akvadrako 6y ago
Panic works fine; they are basically just exceptions you can catch at a higher level. I almost exclusively use panic for my exceptions in go.
- marcus_holmes 6y agoI stopped, because it conflicts so badly with the Go conventions, and because I found myself handling more errors when I didn't use panic. I think this is one of those things that new Gophers find hard to adjust to, and older ones realise the wisdom of (there's a few of these in the Go learning journey!). I'm not impugning your expertise or implying that you're inexperienced. It's just something I've noticed.
- akvadrako 6y agoFor me it was the other direction. I started using err returns because I knew it was idiomatic, but after doing that for months and seeing no benefit I decided it was just idiotic to continue. When I want to handle an error case locally I still use them, but that's extremely rare.