aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--content/defer-panic-and-recover.article2
1 files changed, 1 insertions, 1 deletions
diff --git a/content/defer-panic-and-recover.article b/content/defer-panic-and-recover.article
index 6a05f7c..2c4018c 100644
--- a/content/defer-panic-and-recover.article
+++ b/content/defer-panic-and-recover.article
@@ -171,7 +171,7 @@ If we remove the deferred function from f the panic is not recovered and reaches
-For a real-world example of *panic* and *recover*, see the [[https://golang.org/pkg/encoding/json/][json package]] from the Go standard library. It decodes JSON-encoded data with a set of recursive functions. When malformed JSON is encountered, the parser calls panic to unwind the stack to the top-level function call, which recovers from the panic and returns an appropriate error value (see the 'error' and 'unmarshal' methods of the decodeState type in [[https://golang.org/src/pkg/encoding/json/decode.go][decode.go]]).
+For a real-world example of *panic* and *recover*, see the [[https://golang.org/pkg/encoding/json/][json package]] from the Go standard library. It encodes an interface with a set of recursive functions. If an error occurs when traversing the value, panic is called to unwind the stack to the top-level function call, which recovers from the panic and returns an appropriate error value (see the 'error' and 'marshal' methods of the encodeState type in [[https://golang.org/src/pkg/encoding/json/encode.go][encode.go]]).
The convention in the Go libraries is that even when a package uses panic internally, its external API still presents explicit error return values.