The Elvish shell <https://github.com/elves/elvish/> uses panic capture to ensure an interactive Elvish shell that paniced is replaced by a recovery shell. While still outputting important information about the panic. See this code <https://github.com/elves/elvish/blob/684cfc2c82d71f9a1e35fbf5d6dc4874dfe45bde/pkg/shell/interact.go#L132-L143>. In other words, sometimes you want to ensure that a) information about the panic is captured (such as logging the panic via an external service) and b) doing something other than simply terminating. Whether to capture a panic is obviously dependent on the specific situation.
I'll also note that I'm working on a change to the Elvish project that will capture a panic to solve the problem of the builtin "exit" command not triggering deferred behaviors; such as capturing profiling data. See this issue <http://issue-1377-exit-and-defers>. So that is another, highly context dependent, case where capturing a panic is useful. I've got to say that Go's panic/recover mechanism is a beautiful design. On Sun, Oct 9, 2022 at 2:17 PM cg-guy <mohamedash...@gmail.com> wrote: > Hi Team, > > Whatever I have been worked so far with golang,I did not use recover() > function . > Curious to know if anyone using recover in production code and can you > please > the scenarios where it is used. > > Thanks > > -- > You received this message because you are subscribed to the Google Groups > "golang-nuts" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to golang-nuts+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/golang-nuts/00f1a25f-2f95-4ed7-8acd-6510bae85c30n%40googlegroups.com > <https://groups.google.com/d/msgid/golang-nuts/00f1a25f-2f95-4ed7-8acd-6510bae85c30n%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- Kurtis Rader Caretaker of the exceptional canines Junior and Hank -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CABx2%3DD9m0EGmP%2Bya%2BXSRgd92a9yM2b61RV0QbQ31ci11zX9kyA%40mail.gmail.com.