Skip to content

doc: clarify description of recover in go_spec #64511

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions doc/go_spec.html
Original file line number Diff line number Diff line change
Expand Up @@ -7641,10 +7641,13 @@ <h3 id="Handling_panics">Handling panics</h3>
The <code>recover</code> function allows a program to manage behavior
of a panicking goroutine.
Suppose a function <code>G</code> defers a function <code>D</code> that calls
<code>recover</code> and a panic occurs in a function on the same goroutine in which <code>G</code>
<code>recover</code> and a panic occurs (i.e., <code>panic</code> is called)
in a function on the same goroutine in which <code>G</code>
is executing.
When the running of deferred functions reaches <code>D</code>,
the return value of <code>D</code>'s call to <code>recover</code> will be the value passed to the call of <code>panic</code>.
Subsequently, when the running of deferred functions reaches <code>D</code>,
the return value of <code>D</code>'s call to <code>recover</code> is the value
that was previously passed to <code>panic</code> (i.e., at the call to <code>panic</code>
that caused the deferred functions to run).
If <code>D</code> returns normally, without starting a new
<code>panic</code>, the panicking sequence stops. In that case,
the state of functions called between <code>G</code> and the call to <code>panic</code>
Expand Down