From 76f3228520cd862875d35b3f651be285b489b131 Mon Sep 17 00:00:00 2001
From: Robert Griesemer
-for i := 0; i < 5; i++ {
+for i := 0; i < 5; i++ {
defer fmt.Printf("%d ", i)
}
@@ -1486,7 +1486,7 @@ for a min function that chooses the least of a list of integers:
func Min(a ...int) int {
min := int(^uint(0) >> 1) // largest int
for _, i := range a {
- if i < min {
+ if i < min {
min = i
}
}
@@ -2670,7 +2670,7 @@ suppresses the usual check for a return statement.
// A toy implementation of cube root using Newton's method.
func CubeRoot(x float64) float64 {
z := x/3 // Arbitrary intitial value
- for i := 0; i < 1e6; i++ {
+ for i := 0; i < 1e6; i++ {
prevz := z
z -= (z*z*z-x) / (3*z*z)
if veryClose(z, prevz) {
@@ -2727,7 +2727,7 @@ inside a server without killing the other executing goroutines.
-func server(workChan <-chan *Work) {
+func server(workChan <-chan *Work) {
for work := range workChan {
go safelyDo(work)
}
@@ -2751,7 +2751,16 @@ calling recover handles the condition completely.
-Note that with this recovery pattern in place, the do
+Because recover always returns nil unless called directly
+from a deferred function, deferred code can call library routines that themselves
+use panic and recover without failing. As an example,
+the deferred function in safelyDo might call a logging function before
+calling recover, and that logging code would run unaffected
+by the panicking state.
+
+
+
+With our recovery pattern in place, the do
function (and anything it calls) can get out of any bad situation
cleanly by calling panic. We can use that idea to
simplify error handling in complex software. Let's look at an
diff --git a/doc/go_spec.html b/doc/go_spec.html
index 9784222195..2c6046a7c5 100644
--- a/doc/go_spec.html
+++ b/doc/go_spec.html
@@ -1,5 +1,5 @@
-
+
Bootstrapping
--
2.52.0