Documentation ¶
Overview ¶
Package gdebug contains facilities for programs to debug themselves while they are running.
Index ¶
- func BinVersion() string
- func BinVersionMd5() string
- func Caller(skip ...int) (function string, path string, line int)
- func CallerDirectory() string
- func CallerFileLine() string
- func CallerFileLineShort() string
- func CallerFilePath() string
- func CallerFunction() string
- func CallerPackage() string
- func CallerWithFilter(filters []string, skip ...int) (function string, path string, line int)
- func FuncName(f interface{}) string
- func FuncPath(f interface{}) string
- func GoroutineId() int
- func PrintStack(skip ...int)
- func Stack(skip ...int) string
- func StackWithFilter(filters []string, skip ...int) string
- func StackWithFilters(filters []string, skip ...int) string
- func TestDataContent(names ...string) string
- func TestDataPath(names ...string) string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BinVersion ¶ added in v1.9.3
func BinVersion() string
BinVersion returns the version of current running binary. It uses ghash.BKDRHash+BASE36 algorithm to calculate the unique version of the binary.
func BinVersionMd5 ¶ added in v1.9.3
func BinVersionMd5() string
BinVersionMd5 returns the version of current running binary. It uses MD5 algorithm to calculate the unique version of the binary.
func Caller ¶
Caller returns the function name and the absolute file path along with its line number of the caller.
func CallerDirectory ¶
func CallerDirectory() string
CallerDirectory returns the directory of the caller.
func CallerFileLine ¶
func CallerFileLine() string
CallerFileLine returns the file path along with the line number of the caller.
func CallerFileLineShort ¶ added in v1.10.0
func CallerFileLineShort() string
CallerFileLineShort returns the file name along with the line number of the caller.
func CallerFilePath ¶
func CallerFilePath() string
CallerFilePath returns the file path of the caller.
func CallerFunction ¶
func CallerFunction() string
CallerFunction returns the function name of the caller.
func CallerPackage ¶
func CallerPackage() string
CallerPackage returns the package name of the caller.
func CallerWithFilter ¶
CallerWithFilter returns the function name and the absolute file path along with its line number of the caller.
The parameter `filters` is used to filter the path of the caller.
func FuncName ¶ added in v1.10.0
func FuncName(f interface{}) string
FuncName returns the function name of given `f`.
func FuncPath ¶ added in v1.10.0
func FuncPath(f interface{}) string
FuncPath returns the complete function path of given `f`.
func GoroutineId ¶ added in v1.13.4
func GoroutineId() int
GoroutineId retrieves and returns the current goroutine id from stack information. Be very aware that, it is with low performance as it uses runtime.Stack function. It is commonly used for debugging purpose.
func PrintStack ¶
func PrintStack(skip ...int)
PrintStack prints to standard error the stack trace returned by runtime.Stack.
func Stack ¶
Stack returns a formatted stack trace of the goroutine that calls it. It calls runtime.Stack with a large enough buffer to capture the entire trace.
func StackWithFilter ¶
StackWithFilter returns a formatted stack trace of the goroutine that calls it. It calls runtime.Stack with a large enough buffer to capture the entire trace.
The parameter `filter` is used to filter the path of the caller.
func StackWithFilters ¶
StackWithFilters returns a formatted stack trace of the goroutine that calls it. It calls runtime.Stack with a large enough buffer to capture the entire trace.
The parameter `filters` is a slice of strings, which are used to filter the path of the caller.
TODO Improve the performance using debug.Stack.
func TestDataContent ¶ added in v1.16.6
TestDataContent retrieves and returns the file content for specified testdata path of current package
func TestDataPath ¶ added in v1.11.7
TestDataPath retrieves and returns the testdata path of current package, which is used for unit testing cases only. The optional parameter `names` specifies the sub-folders/sub-files, which will be joined with current system separator and returned with the path.
Types ¶
This section is empty.