Documentation
¶
Overview ¶
Package safe provides panic-safe goroutine helpers. A panic in a worker goroutine (e.g. parsing a malformed provider stream, an index-out-of-range on an empty API response) is not recoverable by the goroutine that spawned it and crashes the entire process. These helpers recover and log the panic instead, and let the caller signal downstream (close a channel, emit an error) so consumers don't hang — turning "one bad response kills the process" into "one failed turn".
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Recover ¶
func Recover(name string)
Recover recovers and logs a panic (with stack). Defer it at the top of a goroutine whose body has its own cleanup defers (e.g. a channel close):
go func() {
defer close(outChan) // still runs after the panic is recovered
defer safe.Recover("x") // recovers so the process survives
...
}()
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.