Browse Source

修正dial.go中格式化输出语句 (#411)

* 修正dial.go例子中格式化输出语句的错误

* 修正dial.go例子中格式化输出语句的错误
Eawaun 7 months ago
parent
commit
c39e071188
2 changed files with 4 additions and 4 deletions
  1. 2 2
      eBook/15.1.md
  2. 2 2
      eBook/examples/chapter_15/dial.go

+ 2 - 2
eBook/15.1.md

@@ -142,10 +142,10 @@ func main() {
142 142
 }
143 143
 func checkConnection(conn net.Conn, err error) {
144 144
 	if err != nil {
145
-		fmt.Printf("error %v connecting!")
145
+		fmt.Printf("error %v connecting!", err)
146 146
 		os.Exit(1)
147 147
 	}
148
-	fmt.Println("Connection is made with %v", conn)
148
+	fmt.Printf("Connection is made with %v\n", conn)
149 149
 }
150 150
 ```
151 151
 下边也是一个使用net包从socket中打开,写入,读取数据的例子:

+ 2 - 2
eBook/examples/chapter_15/dial.go

@@ -17,8 +17,8 @@ func main() {
17 17
 }
18 18
 func checkConnection(conn net.Conn, err error) {
19 19
 	if err != nil {
20
-		fmt.Printf("error %v connecting!")
20
+		fmt.Printf("error %v connecting!", err)
21 21
 		os.Exit(1)
22 22
 	}
23
-	fmt.Println("Connection is made with %v", conn)
23
+	fmt.Printf("Connection is made with %v\n", conn)
24 24
 }