gdebug

package
v0.0.0-...-2910145 Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package gdebug 包含一些工具,可以让程序在运行时自我调试。

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BinVersion

func BinVersion() string

BinVersion 返回当前运行二进制文件的版本。 它采用 ghash.BKDRHash+BASE36 算法来计算二进制文件的唯一版本。

func BinVersionMd5

func BinVersionMd5() string

BinVersionMd5 返回当前运行二进制文件的版本。 它使用MD5算法来计算该二进制文件的唯一版本。

func Caller

func Caller(skip ...int) (function string, path string, line int)

Caller 返回调用者函数的名称以及其所在的绝对文件路径及行号。

func CallerDirectory

func CallerDirectory() string

CallerDirectory 返回调用者所在的目录。

func CallerFileLine

func CallerFileLine() string

CallerFileLine 返回调用者所在的文件路径及行号。

func CallerFileLineShort

func CallerFileLineShort() string

CallerFileLineShort 返回调用者所在的文件名及行号。

func CallerFilePath

func CallerFilePath() string

CallerFilePath 返回调用者所在的文件路径。

func CallerFunction

func CallerFunction() string

CallerFunction 返回调用者函数的名称。

func CallerPackage

func CallerPackage() string

CallerPackage 返回调用者的包名。

func CallerWithFilter

func CallerWithFilter(filters []string, skip ...int) (function string, path string, line int)

CallerWithFilter 返回调用者函数名称以及绝对文件路径及其行号。

参数`filters`用于过滤调用者路径。

func FuncName

func FuncName(f interface{}) string

FuncName 返回给定函数 `f` 的函数名称。

func FuncPath

func FuncPath(f interface{}) string

FuncPath 返回给定函数 `f` 的完整函数路径。

func GoroutineId

func GoroutineId() int

GoroutineId 从堆栈信息中获取并返回当前 goroutine 的 ID。 需要注意的是,由于它使用了 runtime.Stack 函数,所以性能较低。 该函数通常用于调试目的。

func PrintStack

func PrintStack(skip ...int)

PrintStack 将由 runtime.Stack 返回的堆栈跟踪信息打印到标准错误输出。

func Stack

func Stack(skip ...int) string

Stack 函数返回调用该函数的 goroutine 格式化的堆栈跟踪信息。 它通过调用 runtime.Stack 并传入足够大的缓冲区来捕获整个跟踪信息。

func StackWithFilter

func StackWithFilter(filters []string, skip ...int) string

StackWithFilter 返回调用该函数的goroutine格式化后的堆栈跟踪。 它通过传入足够大的缓冲区来调用runtime.Stack,以便捕获整个跟踪信息。

参数`filter`用于过滤调用者路径。

func StackWithFilters

func StackWithFilters(filters []string, skip ...int) string

StackWithFilters 返回调用该函数的goroutine格式化后的堆栈跟踪。 它通过传递足够大的缓冲区调用runtime.Stack,以捕获整个跟踪信息。

参数`filters`是一个字符串切片,用于过滤调用者路径。

TODO 使用debug.Stack改进性能。

Types

This section is empty.

Jump to

Keyboard shortcuts

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