runtimeutils

package
v0.0.0-...-c201010 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2023 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package caller get information regarding caller stack.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoFramesWereFound    = errors.New("no caller frames were provided")
	ErrNoCallerInfoWasFound = errors.New("no caller information was found")
	ErrMaxStackIsLowerThan1 = errors.New("maxStack argument is lower than 1")
)

Functions

func GetCallerFunctionName

func GetCallerFunctionName() string

GetCallerFunctionName return the name of whom called this function

Types

type CallerInfo

type CallerInfo struct {
	Entry   uintptr
	LineNo  int
	Package string
	Func    string
	File    string
}

CallerInfo holds information regarding a given caller frame

func GetCallerInfo

func GetCallerInfo(callerSkipFrames int) (CallerInfo, error)

GetCallerInfo returns a struct of CallerInfo regarding the caller frame requested by callerSkipFrames.

With callerSkipFrames, when value is 0 - It will return runtime.Callers, When callerSkipFrames is 1, it will return GetCallerInfo. So it is recommended to set callerSkipFrames for 2 or beyond to get the current caller for information.

func GetCallerStack

func GetCallerStack(callerSkipFrames, maxStack int) ([]CallerInfo, error)

GetCallerStack provides a list of all stack level (from callerSkipFrames and up to most of maxStack or the latest element that was read).

With callerSkipFrames, when value is 0 - It will return runtime.Callers, When callerSkipFrames is 1, it will return GetCallerInfo. So it is recommended to set callerSkipFrames for 2 or beyond to get the current caller for information.

maxStack must be bigger than 0 or an error will be returned.

func (CallerInfo) DebugInfo

func (ci CallerInfo) DebugInfo() string

DebugInfo provides string with verbose information of each field

func (CallerInfo) FileName

func (ci CallerInfo) FileName() string

FileName returns only the file name without the rest of the path.

func (CallerInfo) PackageName

func (ci CallerInfo) PackageName() string

PackageName returns only the Package name and ignoring the rest of the path.

func (CallerInfo) String

func (ci CallerInfo) String() string

Jump to

Keyboard shortcuts

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