From aadf4f12fee89b5aaa1566daf3319d7bfcda0a2d Mon Sep 17 00:00:00 2001 From: Grenade Date: Thu, 22 Nov 2018 20:22:11 +0800 Subject: [PATCH] fix sample code bug & reformat some sample code (#557) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Update 01.2.md 删除: - 不支持断言 * Formatting 问题5.1 code * Formatting 问题5.3 code * Correct the translation - correct `令 v := map1[key1] 可以将 key1 对应的值赋值为 v` to `令 v := map1[key1] 可以将 key1 对应的值赋值给 v` * Modified sample code - Add `defer fi.Close()` on `示例 12.7` * Reformatting some sample code on 13.3 * Update 14.2.md * Reformatting the sample code. --- eBook/12.2.md | 1 + eBook/13.3.md | 2 +- eBook/14.2.md | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/eBook/12.2.md b/eBook/12.2.md index 54321c1..35f8d2a 100644 --- a/eBook/12.2.md +++ b/eBook/12.2.md @@ -189,6 +189,7 @@ func main() { err) os.Exit(1) } + defer fi.Close() fz, err := gzip.NewReader(fi) if err != nil { r = bufio.NewReader(fi) diff --git a/eBook/13.3.md b/eBook/13.3.md index bbe774d..642588d 100644 --- a/eBook/13.3.md +++ b/eBook/13.3.md @@ -14,7 +14,7 @@ func protect(g func()) { log.Println("done") // Println executes normally even if there is a panic if err := recover(); err != nil { - log.Printf("run time panic: %v", err) + log.Printf("run time panic: %v", err) } }() log.Println("start") diff --git a/eBook/14.2.md b/eBook/14.2.md index 91f4c3a..ce06731 100644 --- a/eBook/14.2.md +++ b/eBook/14.2.md @@ -557,7 +557,7 @@ go processChannel(sendChan, receiveChan) func processChannel(in <-chan int, out chan<- string) { for inValue := range in { result := ... /// processing inValue - out <- result + out <- result } } ```