Documentation
¶
Index ¶
- Variables
- func BytesPointer(data []byte) unsafe.Pointer
- func GetCallStack(size int) string
- func GetCaller(skip int) string
- func GetCallerFrame(skip int) *runtime.Frame
- func GetCallerFuncFileLine(skip int) (caller string, file string, line int)
- func GetCallerPC(skip int) uintptr
- func GetEIP(uintptr) uintptr
- func GetShortCaller(skip int) string
- func GetShortCallerFuncFileLine(skip int) (caller string, file string, line int)
- func RecoverFromPanic(err error) error
- type Panic
Examples ¶
Constants ¶
This section is empty.
Variables ¶
Functions ¶
func BytesPointer ¶
BytesPointer returns a pointer which can be used by CGO
func GetCallStack ¶
GetCallStack Same as stdlib http server code. Manually allocate stack trace buffer size to prevent excessively large logs
func GetCaller ¶
GetCaller returns the caller of the function that calls it. The argument skip is the number of stack frames to skip before recording in pc, with 0 identifying the frame for Callers itself and 1 identifying the caller of Callers.
Example ¶
package main
import (
"fmt"
runtime_ "github.com/searKing/golang/go/runtime"
)
func main() {
caller := runtime_.GetCaller(1)
fmt.Print(caller)
}
Output: github.com/searKing/golang/go/runtime_test.ExampleGetCaller
func GetCallerFrame ¶
GetCallerFrame returns the caller frame of the function that calls it. The argument skip is the number of stack frames to skip before recording in pc, with 0 identifying the frame for Callers itself and 1 identifying the caller of Callers.
func GetCallerFuncFileLine ¶
GetCallerFuncFileLine returns the __FUNCTION__, __FILE__ and __LINE__ of the function that calls it. The argument skip is the number of stack frames to skip before recording in pc, with 0 identifying the frame for Callers itself and 1 identifying the caller of Callers.
func GetCallerPC ¶ added in v1.2.99
GetCallerPC returns the caller PC of the function that calls it. The argument skip is the number of stack frames to skip before recording in pc, with 0 identifying the frame for Callers itself and 1 identifying the caller of Callers.
func GetShortCaller ¶
GetShortCaller returns the short form of GetCaller. The argument skip is the number of stack frames to skip before recording in pc, with 0 identifying the frame for Callers itself and 1 identifying the caller of Callers.
func GetShortCallerFuncFileLine ¶
GetShortCallerFuncFileLine returns the short form of GetCallerFuncFileLine. The argument skip is the number of stack frames to skip before recording in pc, with 0 identifying the frame for Callers itself and 1 identifying the caller of Callers.
Example ¶
package main
import (
"fmt"
runtime_ "github.com/searKing/golang/go/runtime"
)
func main() {
caller, file, line := runtime_.GetShortCallerFuncFileLine(1)
fmt.Printf("%s() %s:%d", caller, file, line)
}
Output: ExampleGetShortCallerFuncFileLine() example_test.go:22
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 ¶
func HandlePanicWith(handlers ...func(interface{})) Panic
func (*Panic) AppendHandler ¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package cgosymbolizer contains runtime support for code generated by the cgo tool.
|
Package cgosymbolizer contains runtime support for code generated by the cgo tool. |