Documentation ¶
Overview ¶
Package xruntime provides extended utility functions for runtime
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Frame ¶
type Frame struct { ShortFilePath string FullFilePath string LineNumber int PackageName string FunctionName string // contains filtered or unexported fields }
Frame is a stack frame
func CaptureFrame ¶
func CaptureFrame() *Frame
CaptureFrame to capture the current stack frame
Example ¶
f := CaptureFrame() fmt.Printf("PackageName: %s\n", f.PackageName) fmt.Printf("FunctionName: %s\n", f.FunctionName) fmt.Printf("ShortFilePath: %s\n", f.ShortFilePath) fmt.Printf("LineNumber: %d\n", f.LineNumber)
Output: PackageName: github.com/speedland/go/x/xruntime FunctionName: ExampleCaptureFrame ShortFilePath: github.com/speedland/go/x/xruntime/xruntime_test.go LineNumber: 13
Example (ForStructFunc) ¶
f := (&T{}).F() fmt.Printf("PackageName: %s\n", f.PackageName) fmt.Printf("FunctionName: %s\n", f.FunctionName) fmt.Printf("ShortFilePath: %s\n", f.ShortFilePath) fmt.Printf("LineNumber: %d\n", f.LineNumber)
Output: PackageName: github.com/speedland/go/x/xruntime FunctionName: (*T).F ShortFilePath: github.com/speedland/go/x/xruntime/xruntime_test.go LineNumber: 28
func CaptureStack ¶
CaptureStack returns a list of stack frames as []*Frame
Example ¶
frames := CaptureStack(50) fmt.Println(frames[0])
Output: github.com/speedland/go/x/xruntime.ExampleCaptureStack (at github.com/speedland/go/x/xruntime/xruntime_test.go#6)
func CaptureStackFrom ¶
CaptureStackFrom is like CaptureStack but skip the given number of frames
Click to show internal directories.
Click to hide internal directories.