removed all the footers; formated all the files
This commit is contained in:
29
2.7.md
29
2.7.md
@@ -115,19 +115,19 @@ channel通过操作符`<-`来接收和发送数据
|
||||
)
|
||||
|
||||
func fibonacci(n int, c chan int) {
|
||||
x, y := 1, 1
|
||||
for i := 0; i < n; i++ {
|
||||
c <- x
|
||||
x, y = y, x + y
|
||||
}
|
||||
close(c)
|
||||
x, y := 1, 1
|
||||
for i := 0; i < n; i++ {
|
||||
c <- x
|
||||
x, y = y, x + y
|
||||
}
|
||||
close(c)
|
||||
}
|
||||
|
||||
func main() {
|
||||
c := make(chan int, 10)
|
||||
go fibonacci(cap(c), c)
|
||||
for i := range c {
|
||||
fmt.Println(i)
|
||||
fmt.Println(i)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -149,13 +149,13 @@ channel通过操作符`<-`来接收和发送数据
|
||||
func fibonacci(c, quit chan int) {
|
||||
x, y := 1, 1
|
||||
for {
|
||||
select {
|
||||
case c <- x:
|
||||
x, y = y, x + y
|
||||
case <-quit:
|
||||
select {
|
||||
case c <- x:
|
||||
x, y = y, x + y
|
||||
case <-quit:
|
||||
fmt.Println("quit")
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -187,6 +187,3 @@ channel通过操作符`<-`来接收和发送数据
|
||||
* [目录](<preface.md>)
|
||||
* 上一章: [interface](<2.6.md>)
|
||||
* 下一节: [总结](<2.8.md>)
|
||||
|
||||
## LastModified
|
||||
* $Id$
|
||||
|
||||
Reference in New Issue
Block a user