mirror of
https://github.com/openimsdk/open-im-server.git
synced 2026-05-01 07:35:58 +08:00
Refactor code
This commit is contained in:
@@ -5,6 +5,7 @@ import (
|
||||
"github.com/pkg/errors"
|
||||
"runtime"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// copy a by b b->a
|
||||
@@ -24,3 +25,15 @@ func printCallerNameAndLine() string {
|
||||
pc, _, line, _ := runtime.Caller(2)
|
||||
return runtime.FuncForPC(pc).Name() + "()@" + strconv.Itoa(line) + ": "
|
||||
}
|
||||
|
||||
func GetSelfFuncName() string {
|
||||
pc, _, _, _ := runtime.Caller(1)
|
||||
return cleanUpFuncName(runtime.FuncForPC(pc).Name())
|
||||
}
|
||||
func cleanUpFuncName(funcName string) string {
|
||||
end := strings.LastIndex(funcName, ".")
|
||||
if end == -1 {
|
||||
return ""
|
||||
}
|
||||
return funcName[end+1:]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user