mirror of
https://github.com/unknwon/the-way-to-go_ZH_CN.git
synced 2025-08-12 04:48:29 +08:00
fix: coding style and file format for chapter 11, 12, 13, 14 and 15.
This commit is contained in:
@@ -1,21 +1,22 @@
|
||||
package main
|
||||
|
||||
import "fmt"
|
||||
import "time"
|
||||
|
||||
func main() {
|
||||
c := make(chan int, 50)
|
||||
go func() {
|
||||
time.Sleep(15 * 1e9)
|
||||
x := <-c
|
||||
fmt.Println("received", x)
|
||||
}()
|
||||
fmt.Println("sending", 10)
|
||||
c <- 10
|
||||
fmt.Println("sent", 10)
|
||||
}
|
||||
/* Output:
|
||||
sending 10
|
||||
sent 10 // prints immediately
|
||||
no further output, because main() then stops
|
||||
*/
|
||||
package main
|
||||
|
||||
import "fmt"
|
||||
import "time"
|
||||
|
||||
func main() {
|
||||
c := make(chan int, 50)
|
||||
go func() {
|
||||
time.Sleep(15 * 1e9)
|
||||
x := <-c
|
||||
fmt.Println("received", x)
|
||||
}()
|
||||
fmt.Println("sending", 10)
|
||||
c <- 10
|
||||
fmt.Println("sent", 10)
|
||||
}
|
||||
|
||||
/* Output:
|
||||
sending 10
|
||||
sent 10 // prints immediately
|
||||
no further output, because main() then stops
|
||||
*/
|
||||
|
Reference in New Issue
Block a user