mirror of
https://github.com/unknwon/the-way-to-go_ZH_CN.git
synced 2025-11-13 17:36:12 +08:00
update book code
This commit is contained in:
16
eBook/exercises/chapter_14/gosum.go
Executable file
16
eBook/exercises/chapter_14/gosum.go
Executable file
@@ -0,0 +1,16 @@
|
||||
// gosum.go
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
func sum(x, y int, c chan int) {
|
||||
c <- x + y
|
||||
}
|
||||
|
||||
func main() {
|
||||
c := make(chan int)
|
||||
go sum(12, 13, c)
|
||||
fmt.Println(<-c) // 25
|
||||
}
|
||||
Reference in New Issue
Block a user