Files
the-way-to-go_ZH_CN/eBook/exercises/chapter_14/gosum.go
2015-03-03 12:25:25 -05:00

17 lines
190 B
Go
Executable File

// 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
}