mirror of
https://github.com/unknwon/the-way-to-go_ZH_CN.git
synced 2025-08-12 03:34:15 +08:00
17 lines
190 B
Go
Executable File
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
|
|
}
|