diff --git a/doc/go_spec.html b/doc/go_spec.html index 53f079a2f7..bf96322517 100644 --- a/doc/go_spec.html +++ b/doc/go_spec.html @@ -1,6 +1,6 @@ @@ -5270,14 +5270,14 @@ func recover() interface{}
-A panic call in a function F terminates the execution
-of F.
+While executing a function F,
+an explicit call to panic or a run-time panic
+terminates the execution of F.
Any functions deferred by F
-are executed before F returns to its caller. To the caller,
-the call of F then behaves itself like a call to panic,
-terminating its own execution and running deferred functions in the same manner.
-This continues until all functions in the goroutine have ceased execution,
-in reverse order. At that point, the program is terminated and the error
+are then executed as usual.
+Next, any deferred functions run by F's caller are run,
+and so on up to any deferred by the top-level function in the executing goroutine.
+At that point, the program is terminated and the error
condition is reported, including the value of the argument to panic.
This termination sequence is called panicking.
The recover function allows a program to manage behavior
-of a panicking goroutine. Executing a recover call
-inside a deferred function (but not any function called by it) stops
-the panicking sequence by restoring normal execution, and retrieves
-the error value passed to the call of panic. If
-recover is called outside the deferred function it will
-not stop a panicking sequence. In this case, or when the goroutine
-is not panicking, or if the argument supplied to panic
-was nil, recover returns nil.
+of a panicking goroutine.
+Suppose a function G defers a function D that calls
+recover and a panic occurs in a function on the same goroutine in which G
+is executing.
+When the running of deferred functions reaches D,
+the return value of D's call to recover will be the value passed to the call of panic.
+If D returns normally, without starting a new
+panic, the panicking sequence stops. In that case,
+the state of functions called between G and the call to panic
+is discarded, and normal execution resumes.
+Any functions deferred by G before D are then run and G's
+execution terminates by returning to its caller.
+The return value of recover is nil if any of the following conditions holds:
+
panic's argument was nil;
+recover was not called directly by a deferred function.
+
The protect function in the example below invokes
the function argument g and protects callers from