From 837782153ed66853f49a258ad12cfc3f5e1e4f61 Mon Sep 17 00:00:00 2001 From: Larry Battle Date: Mon, 2 Dec 2013 16:41:14 -0600 Subject: [PATCH] Shorter example and formatting. - Refactored the last example because it was too long. - Output should be a comment. --- ebook/07.6.md | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/ebook/07.6.md b/ebook/07.6.md index aa52511c..57a4b9a5 100644 --- a/ebook/07.6.md +++ b/ebook/07.6.md @@ -68,7 +68,7 @@ 在s字符串中去除cutset指定的字符串 fmt.Printf("[%q]", strings.Trim(" !!! Achtung !!! ", "! ")) - Output:["Achtung"] + //Output:["Achtung"] - func Fields(s string) []string @@ -125,30 +125,25 @@ "fmt" "strconv" ) - + func checkError(e error){ + if e != nil{ + fmt.Println(e) + } + } func main() { a, err := strconv.ParseBool("false") - if err != nil { - fmt.Println(err) - } + checkError(err) b, err := strconv.ParseFloat("123.23", 64) - if err != nil { - fmt.Println(err) - } + checkError(err) c, err := strconv.ParseInt("1234", 10, 64) - if err != nil { - fmt.Println(err) - } + checkError(err) d, err := strconv.ParseUint("12345", 10, 64) - if err != nil { - fmt.Println(err) - } + checkError(err) e, err := strconv.Atoi("1023") - if err != nil { - fmt.Println(err) - } + checkError(err) fmt.Println(a, b, c, d, e) } + ## links