if err != nil {
return mherr.WrapErr(err, "optional context")
}
I just wrote a custom function that adds the stack trace to the error. I also have it setup as a code snippet in VS Code so all I have to do is type "if err" and hit tab. Yes it looks a bit verbose but it adds approximately zero extra work and makes error handling extremely easy by default.
Also, turn on log flags to add line numbers.
log.SetFlags(log.Llongfile | log.LstdFlags)
Also, turn on log flags to add line numbers. log.SetFlags(log.Llongfile | log.LstdFlags)