M
M
Michail Wowtschuk2017-03-25 12:06:13
go
Michail Wowtschuk, 2017-03-25 12:06:13

What is the difference between Exit, Panic, Fatal, Recover, what do they do and when is it better to use them?

Help me figure it out, everything is clear with Exit, it completes the program, I understand that I don’t write anything to the log.
How do Panic, Fatal and Recover work?
For example, if I call Panic, Fatal or Recover does it terminate the program and write an error to the log or what?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander Pavlyuk, 2017-03-26
@wowtschuk

In short, log.Fatal is the same Exit, only with a message written to the log.
panic is something like a very serious exception that can usually be caught inside a defer. But there are some types of panics that are impossible to catch because they are related to memory corruption, for example. Such panics, as well as those that we did not catch, will write a stacktrace and terminate the program.

D
Dmitry, 2017-03-25
@TrueBers

Are official sources no longer in vogue?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question