Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultHandleCrash ¶
func DefaultHandleCrash()
DefaultHandleCrash simply catches a crash with the default recover handler.
Example:
go func() {
defer DefaultHandleCrash()
...
}()
func Go ¶
func Go(do DoFunc)
Go starts a recoverable goroutine.
Example:
safe.Go(
func() { ... },
)
func GoR ¶
func GoR(do DoFunc, handlers ...RecoverHandler)
GoR starts a recoverable goroutine using given recover handler.
Example:
safe.GoR(
func() { ... },
customRecoverHandler
)
func HandleCrash ¶
func HandleCrash(handlers ...RecoverHandler)
HandleCrash catches a crash with the custom recover handlers.
Example:
go func() {
defer HandleCrash(customRecoverHandler)
...
}()
Types ¶
type Pool ¶
type Pool struct {
// contains filtered or unexported fields
}
Pool is a pool of go routines.
type RecoverHandler ¶
type RecoverHandler func(r interface{})
var DefaultRecoverHandler RecoverHandler = func(r interface{}) { log.Printf("Recovered in goroutine: %s, stack: %s\n", r, debug.Stack()) }
Click to show internal directories.
Click to hide internal directories.