From 1c0ac14e5e76469ea49ba06db19a3fe4cb8432f0 Mon Sep 17 00:00:00 2001 From: chai2010 Date: Tue, 12 Jan 2016 10:21:40 +0800 Subject: [PATCH] ch5-10: fmt code --- ch5/ch5-10.md | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/ch5/ch5-10.md b/ch5/ch5-10.md index 18b62f0..fd49767 100644 --- a/ch5/ch5-10.md +++ b/ch5/ch5-10.md @@ -47,17 +47,18 @@ func soleTitle(doc *html.Node) (title string, err error) { }() // Bail out of recursion if we find more than one nonempty title. forEachNode(doc, func(n *html.Node) { - if n.Type == html.ElementNode && n.Data == "title" && n.FirstChild != nil { - if title != "" { - panic(bailout{}) // multiple titleelements + if n.Type == html.ElementNode && n.Data == "title" && + n.FirstChild != nil { + if title != "" { + panic(bailout{}) // multiple titleelements + } + title = n.FirstChild.Data } - title = n.FirstChild.Data - } }, nil) if title == "" { return "", fmt.Errorf("no title element") } - return title, nil + return title, nil } ```