From e9525871987a0c2423eabba4fb4abfd1fb797f35 Mon Sep 17 00:00:00 2001 From: Martin Angers Date: Thu, 6 Sep 2012 07:55:07 -0400 Subject: [PATCH] little more idiomatic code in the example --- README.md | 5 ++--- example_test.go | 3 +-- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index b1ba29f..35e78a3 100644 --- a/README.md +++ b/README.md @@ -43,7 +43,7 @@ Taken from example_test.go: ) // This example scrapes the 10 reviews shown on the home page of MetalReview.com, - // the best metal review site on the web :) (no, I'm not affiliated with them) + // the best metal review site on the web :) (and no, I'm not affiliated to them!) func ExampleScrape_MetalReview() { // Load the HTML document (in real use, the type would be *goquery.Document) var doc *Document @@ -60,8 +60,7 @@ Taken from example_test.go: // For each item found, get the band, title and score, and print it band = s.Find("strong").Text() title = s.Find("em").Text() - score, e := strconv.ParseFloat(s.Find(".score").Text(), 64) - if e != nil { + if score, e = strconv.ParseFloat(s.Find(".score").Text(), 64); e != nil { // Not a valid float, ignore score fmt.Printf("Review %d: %s - %s", i, band, title) } else { diff --git a/example_test.go b/example_test.go index 03796dc..f29f41f 100644 --- a/example_test.go +++ b/example_test.go @@ -26,8 +26,7 @@ func ExampleScrape_MetalReview() { // For each item found, get the band, title and score, and print it band = s.Find("strong").Text() title = s.Find("em").Text() - score, e := strconv.ParseFloat(s.Find(".score").Text(), 64) - if e != nil { + if score, e = strconv.ParseFloat(s.Find(".score").Text(), 64); e != nil { // Not a valid float, ignore score fmt.Printf("Review %d: %s - %s", i, band, title) } else {