From 481091c61f863de7e2494f367efa9c905afe2060 Mon Sep 17 00:00:00 2001
From: kilaka
+ Running this program will exit correctly, +even though panic was invoked in two methods. +The recover is responsible for recovering from panics. + + |
+
+
+ $ go run recover.go
+Getting index 10 of array of len 5...
+Recovered. Error:
+ runtime error: index out of range [10] with length 5
+ |
+
+ Note that, in Go it is idiomatic +to use error-indicating return values wherever possible. + + |
+
+
+ About to process i=-1
+Recovered. Error:
+ Accepting only non-negative numbers but received -1
+ |
+
+ Next example: Collection Functions. +
+ + +diff --git a/public/atomic-counters b/public/atomic-counters index a6fef35..b70cbc7 100644 --- a/public/atomic-counters +++ b/public/atomic-counters @@ -236,7 +236,7 @@ state.
diff --git a/public/base64-encoding b/public/base64-encoding index 74ffc9a..9b2150b 100644 --- a/public/base64-encoding +++ b/public/base64-encoding @@ -191,7 +191,7 @@ but they both decode to the original string as desired.
diff --git a/public/channel-buffering b/public/channel-buffering index 0bea69d..fe8793b 100644 --- a/public/channel-buffering +++ b/public/channel-buffering @@ -153,7 +153,7 @@ concurrent receive.
diff --git a/public/channel-directions b/public/channel-directions index 2814e81..763ec5b 100644 --- a/public/channel-directions +++ b/public/channel-directions @@ -145,7 +145,7 @@ receive on this channel.
diff --git a/public/channel-synchronization b/public/channel-synchronization index 804f06c..362b430 100644 --- a/public/channel-synchronization +++ b/public/channel-synchronization @@ -184,7 +184,7 @@ started.
diff --git a/public/channels b/public/channels index c3f4a4a..cde4702 100644 --- a/public/channels +++ b/public/channels @@ -168,7 +168,7 @@ message without having to use any other synchronization.
diff --git a/public/closing-channels b/public/closing-channels
index cba2538..b1b5c67 100644
--- a/public/closing-channels
+++ b/public/closing-channels
@@ -194,7 +194,7 @@ example: range
over channels.
diff --git a/public/closures b/public/closures index 3ef94ee..acb4359 100644 --- a/public/closures +++ b/public/closures @@ -190,7 +190,7 @@ recursion.
diff --git a/public/collection-functions b/public/collection-functions index 6d7db8c..01af859 100644 --- a/public/collection-functions +++ b/public/collection-functions @@ -9,7 +9,7 @@ onkeydown = (e) => { if (e.key == "ArrowLeft") { - window.location.href = 'defer'; + window.location.href = 'recover'; } @@ -371,7 +371,7 @@ type.
diff --git a/public/command-line-arguments b/public/command-line-arguments index a3f61e4..6c2251c 100644 --- a/public/command-line-arguments +++ b/public/command-line-arguments @@ -170,7 +170,7 @@ with flags.
diff --git a/public/command-line-flags b/public/command-line-flags index b308844..ed2b9a9 100644 --- a/public/command-line-flags +++ b/public/command-line-flags @@ -310,7 +310,7 @@ and show the help text again.
diff --git a/public/command-line-subcommands b/public/command-line-subcommands index 60e9928..d226e51 100644 --- a/public/command-line-subcommands +++ b/public/command-line-subcommands @@ -263,7 +263,7 @@ way to parameterize programs.
diff --git a/public/constants b/public/constants index 737bfc0..8e80c8c 100644 --- a/public/constants +++ b/public/constants @@ -183,7 +183,7 @@ assignment or function call. For example, here diff --git a/public/context b/public/context index d808591..6032419 100644 --- a/public/context +++ b/public/context @@ -205,7 +205,7 @@ cancellation.
diff --git a/public/defer b/public/defer index b15ef1e..8630332 100644 --- a/public/defer +++ b/public/defer @@ -14,7 +14,7 @@ if (e.key == "ArrowRight") { - window.location.href = 'collection-functions'; + window.location.href = 'recover'; } } @@ -203,7 +203,7 @@ after being written.
- Next example: Collection Functions. + Next example: Recover.
diff --git a/public/directories b/public/directories
index 0d7d9f5..19a325d 100644
--- a/public/directories
+++ b/public/directories
@@ -353,7 +353,7 @@ recursively by filepath.Walk
.
diff --git a/public/environment-variables b/public/environment-variables index 65b18c9..6015252 100644 --- a/public/environment-variables +++ b/public/environment-variables @@ -186,7 +186,7 @@ program picks that value up.
diff --git a/public/epoch b/public/epoch index 192c24c..5ad5ceb 100644 --- a/public/epoch +++ b/public/epoch @@ -177,7 +177,7 @@ parsing and formatting.
diff --git a/public/errors b/public/errors index be57978..8dce680 100644 --- a/public/errors +++ b/public/errors @@ -299,7 +299,7 @@ on the Go blog for more on error handling.
diff --git a/public/execing-processes b/public/execing-processes
index 687da4a..cfa31cf 100644
--- a/public/execing-processes
+++ b/public/execing-processes
@@ -203,7 +203,7 @@ processes covers most use cases for fork
.
diff --git a/public/file-paths b/public/file-paths index 1e5e204..6c1e6f6 100644 --- a/public/file-paths +++ b/public/file-paths @@ -250,7 +250,7 @@ be made relative to base.
diff --git a/public/for b/public/for index e7b756b..c5273e9 100644 --- a/public/for +++ b/public/for @@ -195,7 +195,7 @@ structures.
diff --git a/public/functions b/public/functions index 2747daa..6fd4d89 100644 --- a/public/functions +++ b/public/functions @@ -193,7 +193,7 @@ multiple return values, which we’ll look at next.
diff --git a/public/goroutines b/public/goroutines index 0defc4c..2ebd5dc 100644 --- a/public/goroutines +++ b/public/goroutines @@ -207,7 +207,7 @@ concurrent Go programs: channels.
diff --git a/public/http-clients b/public/http-clients index d3c773d..e7dc068 100644 --- a/public/http-clients +++ b/public/http-clients @@ -169,7 +169,7 @@ settings.
diff --git a/public/http-servers b/public/http-servers index 72b4ef0..797f74e 100644 --- a/public/http-servers +++ b/public/http-servers @@ -210,7 +210,7 @@ router we’ve just set up.
diff --git a/public/if-else b/public/if-else index b599e09..b684ea3 100644 --- a/public/if-else +++ b/public/if-else @@ -184,7 +184,7 @@ for basic conditions.
diff --git a/public/index.html b/public/index.html index 470a699..129e934 100644 --- a/public/index.html +++ b/public/index.html @@ -109,6 +109,8 @@
+
+
diff --git a/public/interfaces b/public/interfaces
index baf76af..ff1626f 100644
--- a/public/interfaces
+++ b/public/interfaces
@@ -236,7 +236,7 @@ these structs as arguments to measure
.
diff --git a/public/json b/public/json index b39d512..ac13e5e 100644 --- a/public/json +++ b/public/json @@ -416,7 +416,7 @@ for more.
diff --git a/public/line-filters b/public/line-filters index d7e5fea..34f8e9a 100644 --- a/public/line-filters +++ b/public/line-filters @@ -204,7 +204,7 @@ lowercase lines.
diff --git a/public/maps b/public/maps
index c3bb882..25cd47f 100644
--- a/public/maps
+++ b/public/maps
@@ -232,7 +232,7 @@ printed with fmt.Println
.
diff --git a/public/methods b/public/methods index b8e0a58..44c275b 100644 --- a/public/methods +++ b/public/methods @@ -197,7 +197,7 @@ naming related sets of methods: interfaces.
diff --git a/public/multiple-return-values b/public/multiple-return-values index fa3ca35..08ab6eb 100644 --- a/public/multiple-return-values +++ b/public/multiple-return-values @@ -166,7 +166,7 @@ feature of Go functions; we’ll look at this next.
diff --git a/public/mutexes b/public/mutexes index 94208eb..e97f94b 100644 --- a/public/mutexes +++ b/public/mutexes @@ -297,7 +297,7 @@ management task using only goroutines and channels.
diff --git a/public/non-blocking-channel-operations b/public/non-blocking-channel-operations
index ea30fd1..a874f03 100644
--- a/public/non-blocking-channel-operations
+++ b/public/non-blocking-channel-operations
@@ -176,7 +176,7 @@ on both messages
and signals
.
diff --git a/public/number-parsing b/public/number-parsing index e222bc7..798acfd 100644 --- a/public/number-parsing +++ b/public/number-parsing @@ -213,7 +213,7 @@ bits.
diff --git a/public/panic b/public/panic index 9242fcc..eb18040 100644 --- a/public/panic +++ b/public/panic @@ -172,7 +172,7 @@ to use error-indicating return values wherever possible.
diff --git a/public/pointers b/public/pointers index 62d3a70..716f4b3 100644 --- a/public/pointers +++ b/public/pointers @@ -193,7 +193,7 @@ the memory address for that variable.
diff --git a/public/random-numbers b/public/random-numbers index 39f9246..9bbddb1 100644 --- a/public/random-numbers +++ b/public/random-numbers @@ -229,7 +229,7 @@ that Go can provide.
diff --git a/public/range b/public/range
index 81877c9..593785d 100644
--- a/public/range
+++ b/public/range
@@ -200,7 +200,7 @@ of the rune
and the second the rune
itself.
diff --git a/public/range-over-channels b/public/range-over-channels index 6eedb6a..1a36cc9 100644 --- a/public/range-over-channels +++ b/public/range-over-channels @@ -154,7 +154,7 @@ values be received.
diff --git a/public/rate-limiting b/public/rate-limiting index 25900dd..06a79ff 100644 --- a/public/rate-limiting +++ b/public/rate-limiting @@ -261,7 +261,7 @@ then serve the remaining 2 with ~200ms delays each.
diff --git a/public/reading-files b/public/reading-files
index abed995..84cd8e4 100644
--- a/public/reading-files
+++ b/public/reading-files
@@ -287,7 +287,7 @@ be scheduled immediately after Open
ing with
diff --git a/public/recover b/public/recover
new file mode 100644
index 0000000..e12ca15
--- /dev/null
+++ b/public/recover
@@ -0,0 +1,284 @@
+
+
+
+ +
+ + + +
+