利用golang自带包 runtime/debug 异常时打印
DebugInfo.go
package main
import (
"fmt"
"os"
"runtime/debug"
"time"
)
func TryE() {
errs := recover()
if errs == nil {
return
}
exeName := os.Args[0] //获取程序名称
now := time.Now() //获取当前时间
pid := os.Getpid() //获取进程ID
time_str := now.Format("20060102150405")