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