From 45b04fc5670c7583351d5e77137844d942f0af07 Mon Sep 17 00:00:00 2001 From: D Date: Mon, 11 Jan 2016 23:44:13 +0800 Subject: [PATCH] ch5-10 fmt code --- ch5/ch5-10.md | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/ch5/ch5-10.md b/ch5/ch5-10.md index 5c09a41..18b62f0 100644 --- a/ch5/ch5-10.md +++ b/ch5/ch5-10.md @@ -35,15 +35,15 @@ deferred函數幫助Parse從panic中恢複。在deferred函數內部,panic val func soleTitle(doc *html.Node) (title string, err error) { type bailout struct{} defer func() { - switch p := recover(); p { - case nil: - // no panic - case bailout{}: - // "expected" panic - err = fmt.Errorf("multiple title elements") - default: - panic(p) // unexpected panic; carry on panicking - } + switch p := recover(); p { + case nil: + // no panic + case bailout{}: + // "expected" panic + err = fmt.Errorf("multiple title elements") + default: + panic(p) // unexpected panic; carry on panicking + } }() // Bail out of recursion if we find more than one nonempty title. forEachNode(doc, func(n *html.Node) { @@ -65,4 +65,4 @@ func soleTitle(doc *html.Node) (title string, err error) { 有些情況下,我們無法恢複。某些致命錯誤會導致Go在運行時終止程序,如內存不足。 -**練習5.19:** 使用panic和recover編寫一個不包含return語句但能返迴一個非零值的函數。 +**練習5.19:** 使用panic和recover編寫一個不包含return語句但能返迴一個非零值的函數。 \ No newline at end of file