Or the documentation of runtime.Caller mentioning that deferred functions have line numbers that point to the line after return.
What did you see instead?
And no mention of defer in runtime.Caller or runtime.Callers docs.
I understand why it's that way, and I've even created a wonky workaround (on Russian SO, on Playground). But I think that it would be good to mention this behaviour and basic reasoning behind it in the functions' docs.
The text was updated successfully, but these errors were encountered:
Documenting this briefly is fine. I just want to comment that I think the current behavior makes sense. The deferred function is not called at the point of the defer statement. That is where the call is deferred, not where it is made. The deferred function is actually called at the point where the deferring function returns. And that is what runtime.Caller reports.