xruntime

package
v0.0.0-...-ed9fe1d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 2, 2018 License: BSD-3-Clause Imports: 3 Imported by: 0

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 CaptureCaller

func CaptureCaller() *Frame

CaptureCaller returns a frame where a caller is.

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

func CaptureStack(maxDepth int) []*Frame

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

func CaptureStackFrom(skip int, maxDepth int) []*Frame

CaptureStackFrom is like CaptureStack but skip the given number of frames

func (*Frame) String

func (f *Frame) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL