modulepackage
0.0.0-20190812204905-43a7fa316459
Repository: https://github.com/virtuald/go-paniclog.git
Documentation: pkg.go.dev
# README
go-paniclog
By default, panics in golang are sent to stderr. Unfortunately, there isn't a direct builtin global mechanism to capture/send the output of the panic to a file or really do anything with it other than to write to stderr.
One possible solution is that you can redirect stderr to a file, and that's all that this package does. Of course, once you redirect stderr to file, anything else you write to stderr will also end up in that file. v2.0 now includes a function you can use to undo the redirection if you wanted to do that for some reason.
Reference: https://stackoverflow.com/questions/34772012/capturing-panic-in-golang
Alternatives
- panicwrap may be a better solution for many programs
Author
I can't claim any credit for this idea or the code, it is entirely taken from the rclone program by Nick Craig-Wood.
License
MIT License
# Packages
No description provided by the author
# Functions
RedirectStderr to the file passed in, so that the output of any panics that occur will be sent to that file.
# Type aliases
UndoFunction will reverse the redirection.