Handling panics from goroutines

1 · · May 11, 2023, noon
I need to run a given function before exiting from a Go program, either during graceful shutdown or whenever a panic occurs. If a panic occurs within a goroutine, it’s a bit tricky to get the exit/clean-up function at the caller to be run. As it’s critical for the restarting of the program and it involves persisting some state to disk, the correct approach would be one of the following: Implement a recovery protocol: This is something DB system implementers/researchers would recommend since it’...