You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
pikachule edited this page Sep 2, 2017
·
1 revision
package main
import (
"fmt"
)
func g(c chan int) {
sum := 666
c <- sum
}
func sum(s []int, c chan int) {
result := 666
for _, i := range s {
result += i
}
c <- result
}
func main() {
c := make(chan int)
go g(c)
fmt.Println(<-c)
ia := []int{1, 2, 3, 4, 5}
go sum(ia, c)
fmt.Println(<-c)
}