2021
06-19
06-19
Golang 实现获取当前函数名称和文件行号等操作
大家还是直接看代码吧~//获取正在运行的函数名funcrunFuncName()string{pc:=make([]uintptr,1)runtime.Callers(2,pc)f:=runtime.FuncForPC(pc[0])returnf.Name()}packagemainimport("fmt""runtime")//获取正在运行的函数名funcrunFuncName()string{pc:=make([]uintptr,1)runtime.Callers(2,pc)f:=runtime.FuncForPC(pc[0])returnf.Name()}functest1(){i:=0fmt...
继续阅读 >