From a8af695b92e1edff0241cb85fc30966551636b76 Mon Sep 17 00:00:00 2001 From: wahaha Date: Wed, 13 Jun 2018 14:39:59 +0800 Subject: [PATCH 1/4] =?UTF-8?q?1.5=E8=8A=82=E4=BE=8B=E5=AD=90=E4=BF=AE?= =?UTF-8?q?=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ch1-basic/ch1-05-mem.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ch1-basic/ch1-05-mem.md b/ch1-basic/ch1-05-mem.md index b55ac10..fb4c821 100644 --- a/ch1-basic/ch1-05-mem.md +++ b/ch1-basic/ch1-05-mem.md @@ -43,6 +43,8 @@ func worker(wg *sync.WaitGroup) { } func main() { + var wg sync.WaitGroup + wg.Add(2) go worker(&wg) go worker(&wg) wg.Wait() From bfa5e0ace463b8d03769391b7ce62a5dd23d1eaa Mon Sep 17 00:00:00 2001 From: Cloverstd Date: Wed, 13 Jun 2018 21:04:13 +0800 Subject: [PATCH 2/4] typo: `str` should be `s` --- ch1-basic/ch1-03-array-string-and-slice.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ch1-basic/ch1-03-array-string-and-slice.md b/ch1-basic/ch1-03-array-string-and-slice.md index d1fdc8b..1742dfe 100644 --- a/ch1-basic/ch1-03-array-string-and-slice.md +++ b/ch1-basic/ch1-03-array-string-and-slice.md @@ -268,7 +268,7 @@ fmt.Printf("%#v\n", string([]rune{'世', '界'})) // 世界 ```go func forOnString(s string, forBody func(i int, r rune)) { for i := 0; len(s) > 0; { - r, size := utf8.DecodeRuneInString(str) + r, size := utf8.DecodeRuneInString(s) forBody(i, r) s = s[size:] i += size From e4e323e399736b093902dbe16d72191b139f8184 Mon Sep 17 00:00:00 2001 From: wahaha Date: Wed, 13 Jun 2018 23:39:27 +0800 Subject: [PATCH 3/4] =?UTF-8?q?1.5=E8=8A=82=E6=96=87=E5=AD=97=E9=87=8D?= =?UTF-8?q?=E7=BB=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1.5节文字重组 --- ch1-basic/ch1-05-mem.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ch1-basic/ch1-05-mem.md b/ch1-basic/ch1-05-mem.md index fb4c821..7921a3d 100644 --- a/ch1-basic/ch1-05-mem.md +++ b/ch1-basic/ch1-05-mem.md @@ -86,7 +86,7 @@ func main() { `atomic.AddUint64`函数调用保证了`total`的读取、更新和保存是一个原子操作,因此在多线程中访问也是安全的。 -原子操作配合互斥锁可以实现非常高效的单件模式。互斥锁的代价比普通整数的原子读写高很多,在性能敏感的地方可以增加一个数字型的标志位,通过原子检测标志位状态通过降低互斥锁的次数来提高性能。 +原子操作配合互斥锁可以实现非常高效的单件模式。互斥锁的代价比普通整数的原子读写高很多,在性能敏感的地方可以增加一个数字型的标志位,通过原子检测标志位状态降低互斥锁的使用次数来提高性能。 ```go type singleton struct {} From bc5c5d0ed698a1681e8b7379bea4f6f6e6fee840 Mon Sep 17 00:00:00 2001 From: wahaha Date: Thu, 14 Jun 2018 12:37:11 +0800 Subject: [PATCH 4/4] =?UTF-8?q?ch1-5=EF=BC=9A=E6=96=87=E5=AD=97=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ch1-basic/ch1-05-mem.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ch1-basic/ch1-05-mem.md b/ch1-basic/ch1-05-mem.md index 7921a3d..a869dac 100644 --- a/ch1-basic/ch1-05-mem.md +++ b/ch1-basic/ch1-05-mem.md @@ -267,7 +267,7 @@ Go程序的初始化和执行总是从`main.main`函数开始的。但是如果` ## Goroutine的创建 -`go`语句会在当前Goroutine对应函数开始执行前启动新的Goroutine. 例如: +`go`语句会在当前Goroutine对应函数返回前创建新的Goroutine. 例如: ```go