1
0
mirror of https://github.com/fumiama/NanoBot.git synced 2026-06-06 03:00:24 +08:00
Files
NanoBot/helper.go
2023-10-10 22:02:52 +09:00

21 lines
352 B
Go

package nano
import (
"runtime"
"strings"
)
// getCallerFuncName 获取调用者函数名
func getCallerFuncName() string {
pc, _, _, ok := runtime.Caller(2)
if !ok {
return ""
}
fullname := runtime.FuncForPC(pc).Name()
i := strings.LastIndex(fullname, ".") + 1
if i <= 0 || i >= len(fullname) {
return fullname
}
return fullname[i:]
}