1 Star 0 Fork 0

leminewx / gokit

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
trace.go 408 Bytes
一键复制 编辑 原始数据 按行查看 历史
wenxian 提交于 2024-03-15 16:40 . 0.0.2.0:优化网络扫描器工具
package utils
import (
"fmt"
"runtime"
"strings"
)
func TraceCode(msg string) string {
var pcs [32]uintptr
n := runtime.Callers(3, pcs[:]) //跳过前3层调用
var str strings.Builder
str.WriteString(msg + "\nTraceback: ")
for _, pc := range pcs[:n] {
fn := runtime.FuncForPC(pc)
file, line := fn.FileLine(pc)
str.WriteString(fmt.Sprintf("\n\t%s:%d", file, line))
}
return str.String()
}
Go
1
https://gitee.com/leminewx/gokit.git
git@gitee.com:leminewx/gokit.git
leminewx
gokit
gokit
9c69314efcfa

搜索帮助

53164aa7 5694891 3bd8fe86 5694891