Skip to content

Commit c3b6384

Browse files
committed
Merge pull request astaxie#131 from yinsigan/master
这里应该有逗号
2 parents 4749de5 + 5100708 commit c3b6384

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

2.2.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,9 @@ Go对于已声明但未使用的变量会在编译阶段报错,比如下面的
104104
>如下的代码会产生错误
105105
>
106106
>> var a int8
107+
107108
>> var b int32
109+
108110
>> c:=a + b
109111
>
110112
>另外,尽管int的长度是32 bit, 但int 与 int32并不可以互用。

2.7.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ channel通过操作符`<-`来接收和发送数据
8080
fmt.Println(x, y, x + y)
8181
}
8282

83-
默认情况下,channel接收和发送数据都是阻塞的除非另一端已经准备好,这样就使得Goroutines同步变的更加的简单,而不需要显式的lock。所谓阻塞,也就是如果读取(value := <-ch)它将会被阻塞,直到有数据接收。其次,任何发送(ch<-5)将会被阻塞,直到数据被读出。无缓冲channel 是在多个goroutine之间同步很棒的工具。
83+
默认情况下,channel接收和发送数据都是阻塞的,除非另一端已经准备好,这样就使得Goroutines同步变的更加的简单,而不需要显式的lock。所谓阻塞,也就是如果读取(value := <-ch)它将会被阻塞,直到有数据接收。其次,任何发送(ch<-5)将会被阻塞,直到数据被读出。无缓冲channel 是在多个goroutine之间同步很棒的工具。
8484

8585
## Buffered Channels
8686
上面我们介绍了默认的非缓存类型的channel,不过Go也允许指定channel的缓冲大小,很简单,就是channel可以存储多少元素。ch:= make(chan bool, 4),创建了可以存储4个元素的bool 型channel。在这个channel 中,前4个元素可以无阻塞的写入。当写入第5个元素时,代码将会阻塞,直到其他goroutine从channel 中读取一些元素,腾出空间。

0 commit comments

Comments
 (0)