问题描述
log.Fatallog.Fatallog.Fatal
log.Fatallog.Fatallog.Fatal
debug.PrintStack()log.FatalStackTrace()
debug.PrintStack()log.FatalStackTrace()
此外,我不想制作自己的调试/错误处理内容的原因是因为我不希望人们必须学习如何使用我的特殊服装处理代码.我只是想要一些标准的东西,人们可以在以后阅读我的代码并且像
Also, the reason I do not want to make my own debugging/error handling stuff is because I don't want people to have to learn how to use my special costume handling code. I just want something standard where people can read my code later and be like
嗯,好吧,所以它抛出一个错误并执行 X..."
"ah ok, so its throwing an error and doing X..."
了解我的代码的人越少越好:)
The less people have to learn about my code the better :)
推荐答案
LlongfileLshortfile
LlongfileLshortfile
// to change the flags on the default logger
log.SetFlags(log.LstdFlags | log.Lshortfile)
这篇关于你如何让 Golang 程序打印它刚刚调用的错误的行号?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!