众所周知,恐慌会产生一个堆栈跟踪到标准输出(Playground 链接):
panic: runtime error: index out of range
goroutine 1 [running]:
main.main()
/tmp/sandbox579134920/main.go:9 +0x20
似乎当您从恐慌中恢复过来时,recover()
只会返回一个error
描述导致恐慌的原因(Playground 链接)。
runtime error: index out of range
我的问题是,是否可以存储写入标准输出的堆栈跟踪?这提供了比字符串更好的调试信息,runtime error: index out of range
因为它显示了文件中导致恐慌的确切行。
繁星淼淼
HUX布斯
侃侃尔雅
相关分类