trace

package
v1.14.0 Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2023 License: BSD-2-Clause Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CallersFrames = func(callers []uintptr) Frames {
	return runtime.CallersFrames(callers)
}

CallersFrames is only intended to be used in go-testdeep internal tests to cover all cases.

Functions

func FindGoModDir

func FindGoModDir(in string) string

FindGoModDir finds the closest directory containing go.mod file starting from directory in.

func FindGoModDirLinks(in string) string

FindGoModDirLinks finds the closest directory containing go.mod file starting from directory in after cleaning it. If not found, expands symlinks and re-searches.

func IgnorePackage

func IgnorePackage(skip ...int) bool

IgnorePackage records the calling package as ignored one in trace.

func Init

func Init()

Init initializes trace global variables.

func IsIgnoredPackage

func IsIgnoredPackage(pkg string) (ok bool)

IsIgnoredPackage returns true if pkg is ignored, false otherwise. Only intended to be used in go-testdeep internal tests.

func Reset

func Reset()

Reset resets the ignored packages map plus cached mod and GOPATH directories (Init should be called again). Only intended to be used in go-testdeep internal tests.

func SplitPackageFunc

func SplitPackageFunc(fn string) (string, string)

SplitPackageFunc splits a fully qualified function name into its package and function parts:

"foo/bar/test.fn"            → "foo/bar/test", "fn"
"foo/bar/test.X.fn"          → "foo/bar/test", "X.fn"
"foo/bar/test.(*X).fn"       → "foo/bar/test", "(*X).fn"
"foo/bar/test.(*X).fn.func1" → "foo/bar/test", "(*X).fn.func1"
"weird"                      → "", "weird"

func UnignorePackage

func UnignorePackage(skip ...int) bool

UnignorePackage cancels a previous use of IgnorePackage, so the calling package is no longer ignored. Only intended to be used in go-testdeep internal tests.

Types

type Frames

type Frames interface {
	Next() (frame runtime.Frame, more bool)
}

Frames is the interface corresponding to type returned by runtime.CallersFrames. See CallersFrames variable.

type Level

type Level struct {
	Package  string
	Func     string
	FileLine string
}

Level is a level when retrieving a stack trace.

type Stack added in v1.9.1

type Stack []Level

Stack is a simple stack trace.

func Retrieve

func Retrieve(skip int, endFunction string) Stack

Retrieve retrieves a trace and returns it.

func (Stack) Dump added in v1.11.0

func (s Stack) Dump(w io.Writer)

Dump writes the stack to w.

func (Stack) IsRelevant added in v1.11.0

func (s Stack) IsRelevant() bool

IsRelevant returns true if the stack contains more than one level, or if the single level has a path with at least one directory.

func (Stack) Match added in v1.9.1

func (s Stack) Match(i int, pkg string, anyFunc ...string) bool

Match returns true if the ith level of s matches pkg (if not empty) and any function in anyFunc.

If anyFunc is empty, only the package is tested.

If a function in anyFunc ends with "*", only the prefix is checked.

Jump to

Keyboard shortcuts

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