mirror of
https://github.com/unknwon/the-way-to-go_ZH_CN.git
synced 2025-08-12 07:02:11 +08:00
fix: coding style and file format for chapter 11, 12, 13, 14 and 15.
This commit is contained in:
@@ -1,23 +1,23 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
func main() {
|
||||
c := make(chan int)
|
||||
// consumer:
|
||||
go func() {
|
||||
for {
|
||||
fmt.Print(<-c, " ")
|
||||
}
|
||||
}()
|
||||
// producer:
|
||||
for {
|
||||
select {
|
||||
case c <- 0:
|
||||
case c <- 1:
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
func main() {
|
||||
c := make(chan int)
|
||||
// consumer:
|
||||
go func() {
|
||||
for {
|
||||
fmt.Print(<-c, " ")
|
||||
}
|
||||
}()
|
||||
// producer:
|
||||
for {
|
||||
select {
|
||||
case c <- 0:
|
||||
case c <- 1:
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user