From 2acace92c06cdad3262efe38fb767c5a7c20d3fa Mon Sep 17 00:00:00 2001 From: Eli Bendersky Date: Thu, 2 Sep 2021 05:42:07 -0700 Subject: [PATCH] Clarify the panic example with a comment about unreachable code Fixes #390 --- examples/panic/panic.sh | 5 +++++ public/panic | 16 +++++++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/examples/panic/panic.sh b/examples/panic/panic.sh index a851be9..c5a7e1d 100644 --- a/examples/panic/panic.sh +++ b/examples/panic/panic.sh @@ -1,6 +1,11 @@ # Running this program will cause it to panic, print # an error message and goroutine traces, and exit with # a non-zero status. + +# When first panic in `main` fires, the program exits +# without reaching the rest of the code. If you'd like +# to see the program try to create a temp file, comment +# the first panic out. $ go run panic.go panic: a problem diff --git a/public/panic b/public/panic index 2da4cff..cb3ce87 100644 --- a/public/panic +++ b/public/panic @@ -117,6 +117,20 @@ returns an error value that we don’t know how to an error message and goroutine traces, and exit with a non-zero status.

+ + + + + + + + + +

When first panic in main fires, the program exits +without reaching the rest of the code. If you’d like +to see the program try to create a temp file, comment +the first panic out.

+ @@ -166,7 +180,7 @@ to use error-indicating return values wherever possible.