1
This commit is contained in:
parent
67c14c72ff
commit
01573c9947
@ -236,14 +236,15 @@ func PrintCallStack() {
|
|||||||
|
|
||||||
func GetCallStack() string {
|
func GetCallStack() string {
|
||||||
// 获取当前函数的调用者信息
|
// 获取当前函数的调用者信息
|
||||||
pc, file, line, ok := runtime.Caller(1)
|
//pc, file, line, ok := runtime.Caller(1)
|
||||||
|
_, _, _, ok := runtime.Caller(1)
|
||||||
if !ok {
|
if !ok {
|
||||||
fmt.Println("runtime.Caller error")
|
fmt.Println("runtime.Caller error")
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
funcName := runtime.FuncForPC(pc).Name()
|
//funcName := runtime.FuncForPC(pc).Name()
|
||||||
fmt.Printf("Function: %s\nFile: %s\nLine: %d\n", funcName, file, line)
|
//fmt.Printf("Function: %s\nFile: %s\nLine: %d\n", funcName, file, line)
|
||||||
|
|
||||||
// 使用Stack打印完整的调用栈信息,可以用于debug
|
// 使用Stack打印完整的调用栈信息,可以用于debug
|
||||||
buf := make([]byte, 1024)
|
buf := make([]byte, 1024)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user