Documentation ¶
Overview ¶
package longpanic defines `Go` func that creates goroutine with defer that waits for somebody to call `RecoverFromPanic` or panics after timeout.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Go ¶
func Go(fn func())
Go runs fn in a different goroutine with defer statement that: 1. Recovers from panic 2. Waits for somebody to call `RecoverFromPanic` or timeout 3. Panics if nobody calls `RecoverFromPanic`
func RecoverFromPanic ¶
func RecoverFromPanic()
RecoverFromPanic is a signal to not wait for the panic and tries to continue the execution.
func SetTimeout ¶
SetTimeout set the timeout after the program panics.
func WithRecover ¶
func WithRecover(fn func())
WithRecover runs fn with defer statement that: 1. Recovers from panic 2. Waits for somebody to call `RecoverFromPanic` or timeout 3. Panics if nobody calls `RecoverFromPanic`
Types ¶
type LongPanic ¶
type LongPanic struct {
// contains filtered or unexported fields
}
LongPanic is a struct that holds an atomic and a timeout after a defer fn will panic.
func NewLongPanic ¶
NewLongPanic creates LongPanic.
func (*LongPanic) Go ¶
func (l *LongPanic) Go(fn func())
Go runs fn in a different goroutine with defer statement that: 1. Recovers from panic 2. Waits for somebody to call `RecoverFromPanic` or timeout 3. Panics if nobody calls `RecoverFromPanic`
func (*LongPanic) RecoverFromPanic ¶
func (l *LongPanic) RecoverFromPanic()
RecoverFromPanic is a signal to not wait for the panic and tries to continue the execution.
func (*LongPanic) WithRecover ¶
func (l *LongPanic) WithRecover(fn func())
WithRecover runs fn with defer statement that: 1. Recovers from panic 2. Waits for somebody to call `RecoverFromPanic` or timeout 3. Panics if nobody calls `RecoverFromPanic`