This commit is contained in:
astaxie
2013-06-15 23:42:44 +08:00
parent f401f99570
commit d540d0699c

View File

@@ -68,11 +68,11 @@ channel通过操作符`<-`来接收和发送数据
import "fmt" import "fmt"
func sum(a []int, c chan int) { func sum(a []int, c chan int) {
sum := 0 total := 0
for _, v := range a { for _, v := range a {
sum += v total += v
} }
c <- sum // send sum to c c <- total // send total to c
} }
func main() { func main() {