Documentation ¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
Functions ¶
func GetCallStack ¶
GetCallStack Same as stdlib http server code. Manually allocate stack trace buffer size to prevent excessively large logs
func GetCaller ¶
func GetCaller() string
GetCaller returns the caller of the function that calls it.
Example ¶
package main import ( "fmt" "github.com/searKing/golang/go/runtime" ) func main() { caller := runtime.GetCaller() fmt.Print(caller) }
Output: github.com/searKing/golang/go/runtime_test.ExampleGetCaller
func RecoverFromPanic ¶
RecoverFromPanic replaces the specified error with an error containing the original error, and the call tree when a panic occurs. This enables error handlers to handle errors and panics the same way.
Types ¶
type Panic ¶
type Panic struct { // IgnoreCrash controls the behavior of Recover and now defaults false. // if false, crash immediately, rather than eating panics. IgnoreCrash bool // PanicHandlers for something like logging the panic message, shutting down go routines gracefully. PanicHandlers []func(interface{}) }
Panic simply catches a panic and logs an error. Meant to be called via defer. Additional context-specific handlers can be provided, and will be called in case of panic.
func HandlePanicWith ¶ added in v0.0.95
func HandlePanicWith(handlers ...func(interface{})) Panic
func (*Panic) AppendHandler ¶
Click to show internal directories.
Click to hide internal directories.