Skip to content

Commit a0ca9d3

Browse files
committed
Merge pull request astaxie#277 from LarryBattle/patch-1
Shorter example and formatting.
2 parents 340e836 + 7f37709 commit a0ca9d3

File tree

1 file changed

+12
-17
lines changed

1 file changed

+12
-17
lines changed

ebook/07.6.md

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868
在s字符串中去除cutset指定的字符串
6969

7070
fmt.Printf("[%q]", strings.Trim(" !!! Achtung !!! ", "! "))
71-
Output:["Achtung"]
71+
//Output:["Achtung"]
7272

7373
- func Fields(s string) []string
7474

@@ -125,30 +125,25 @@
125125
"fmt"
126126
"strconv"
127127
)
128-
128+
func checkError(e error){
129+
if e != nil{
130+
fmt.Println(e)
131+
}
132+
}
129133
func main() {
130134
a, err := strconv.ParseBool("false")
131-
if err != nil {
132-
fmt.Println(err)
133-
}
135+
checkError(err)
134136
b, err := strconv.ParseFloat("123.23", 64)
135-
if err != nil {
136-
fmt.Println(err)
137-
}
137+
checkError(err)
138138
c, err := strconv.ParseInt("1234", 10, 64)
139-
if err != nil {
140-
fmt.Println(err)
141-
}
139+
checkError(err)
142140
d, err := strconv.ParseUint("12345", 10, 64)
143-
if err != nil {
144-
fmt.Println(err)
145-
}
141+
checkError(err)
146142
e, err := strconv.Atoi("1023")
147-
if err != nil {
148-
fmt.Println(err)
149-
}
143+
checkError(err)
150144
fmt.Println(a, b, c, d, e)
151145
}
146+
152147

153148

154149
## links

0 commit comments

Comments
 (0)