From 572ed6eeedd19ff61910e08de1f11f9b185b7545 Mon Sep 17 00:00:00 2001 From: smart Date: Thu, 21 Jan 2016 17:00:02 +0800 Subject: [PATCH 1/3] fix 10.6.3 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修改语法错误 --- eBook/10.6.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/eBook/10.6.md b/eBook/10.6.md index 18f300e..92275fc 100644 --- a/eBook/10.6.md +++ b/eBook/10.6.md @@ -238,9 +238,9 @@ func main() { 我们知道方法将指针作为接收者不是必须的,如下面的例子,我们只是需要 `Point3` 的值来做计算: ```go -type Point3 struct { x, y, z float } +type Point3 struct { x, y, z float64 } // A method on Point3 -func (p Point3) Abs float { +func (p Point3) Abs() float64 { return math.Sqrt(p.x*p.x + p.y*p.y + p.z*p.z) } ``` From c65641364ea1779e49671818c01154da16da676c Mon Sep 17 00:00:00 2001 From: smart Date: Fri, 22 Jan 2016 12:24:56 +0800 Subject: [PATCH 2/3] fix 14.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修正拼写错误 --- eBook/14.1.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eBook/14.1.md b/eBook/14.1.md index a88f517..624076d 100644 --- a/eBook/14.1.md +++ b/eBook/14.1.md @@ -12,7 +12,7 @@ 解决之道在于同步不同的线程,对数据加锁,这样同时就只有一个线程可以变更数据。在 Go 的标准库 `sync` 中有一些工具用来在低级别的代码中实现加锁;我们在第 [9.3](9.3.md) 节中讨论过这个问题。不过过去的软件开发经验告诉我们这会带来更高的复杂度,更容易使代码出错以及更低的性能,所以这个经典的方法明显不再适合现代多核/多处理器编程:`thread-per-connection` 模型不够有效。 -Go 更倾向于其他的方式,在诸多比较合适的范式中,有个被称作 `Communicating Sequential Processes(顺序通信处理)`(CSP, C. Hoare 发明的)还有一个叫做 `message passing-model(消息传递)`(已经运用在了其他语言中,比如 Eralng)。 +Go 更倾向于其他的方式,在诸多比较合适的范式中,有个被称作 `Communicating Sequential Processes(顺序通信处理)`(CSP, C. Hoare 发明的)还有一个叫做 `message passing-model(消息传递)`(已经运用在了其他语言中,比如 Erlang)。 在 Go 中,应用程序并发处理的部分被称作 `goroutines(协程)`,它可以进行更有效的并发运算。在协程和操作系统线程之间并无一对一的关系:协程是根据一个或多个线程的可用性,映射(多路复用,执行于)在他们之上的;协程调度器在 Go 运行时很好的完成了这个工作。 From 88713d19d9f53253ab2b419aa4371ec6b3260f61 Mon Sep 17 00:00:00 2001 From: smart Date: Sun, 24 Jan 2016 17:04:46 +0800 Subject: [PATCH 3/3] fix 14.4 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 删除多余的字 --- eBook/14.4.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eBook/14.4.md b/eBook/14.4.md index b426d7e..834973c 100644 --- a/eBook/14.4.md +++ b/eBook/14.4.md @@ -128,7 +128,7 @@ Received on channel 1: 94348 - `channel1` 用来接收极坐标 - `channel2` 用来接收笛卡尔坐标 -转换过程需要在协程中进行,从 channel1 中读取然后发哦送到 channel2。实际上做这种计算不提倡使用协程和通道,但是如果运算量很大很耗时,这种方案设计就非常合适了。 +转换过程需要在协程中进行,从 channel1 中读取然后发送到 channel2。实际上做这种计算不提倡使用协程和通道,但是如果运算量很大很耗时,这种方案设计就非常合适了。 练习 14.11: [concurrent_pi.go](exercises/chapter_14/concurrent_pi.go) / [concurrent_pi2.go](exercises/chapter_14/concurrent_pi2.go)