cockroach: github.com/cockroachdb/cockroach/pkg/util/caller Index | Files

package caller

import "github.com/cockroachdb/cockroach/pkg/util/caller"

Index

Package Files

resolver.go

func Lookup Uses

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.

type CallResolver Uses

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 Uses

func NewCallResolver(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 Uses

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.

Package caller imports 5 packages (graph) and is imported by 19 packages. Updated 2019-07-21. Refresh now. Tools for package owners.