caller

package
v0.0.0-...-ad86efc Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2016 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Lookup

func Lookup(depth int) (file string, line int, fun string)

Lookup returns the (reduced) file, line and function of the caller at the requested depth, using a default call resolver which drops the path of the project repository.

Types

type CallResolver

type CallResolver struct {
	// contains filtered or unexported fields
}

A CallResolver is a helping hand around runtime.Caller() to look up file, line and name of the calling function. CallResolver caches the results of its lookups and strips the uninteresting prefix from both the caller's location and name; see NewCallResolver().

func NewCallResolver

func NewCallResolver(offset int, re *regexp.Regexp) *CallResolver

NewCallResolver returns a CallResolver. The supplied pattern must specify a valid regular expression and is used to format the paths returned by Lookup(): If submatches are specified, their concatenation forms the path, otherwise the match of the whole expression is used. Paths which do not match at all are left unchanged. TODO(bdarnell): don't strip paths at lookup time, but at display time; need better handling for callers such as x/tools/something.

func (*CallResolver) Lookup

func (cr *CallResolver) Lookup(depth int) (file string, line int, fun string)

Lookup returns the (reduced) file, line and function of the caller at the requested depth.

Jump to

Keyboard shortcuts

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