-
The log message goes to the configured log output, while panic is only going to write to stderr.
-
Panic will print a stack trace, which may not be relevant to the error at all.
-
Defers will be executed when a program panics, but calling
os.Exitexits immediately, and deferred functions can’t be run.
In general, only use panic for programming errors, where the stack trace is important to the context of the error. If the message isn’t targeted at the programmer, you’re simply hiding the message in superfluous data.