Is it possible to get the line number on which a function returned from the calling scope?
Example:
func callee() error {
if cond {
return errors.New("whoops!")
}
return nil
}
func caller() {
// Possible to retrieve the line number of callee return here?
callee()
}
I assume that's not possible, since it should be already removed from the stack, but maybe it's still cached somewhere?
The use case is that I have a HTTP handler and I'd like to log the line and filename on which the error was returned, without having to litter the code.