content: change variable name in channels example
The code example is summing a slice (s), not an array (a).
Change-Id: Iae4608271a69e1d80fa2c5b09981f5fadc48a3f6
Reviewed-on: https://go-review.googlesource.com/19530
Reviewed-by: Andrew Gerrand <adg@golang.org>
diff --git a/content/concurrency/channels.go b/content/concurrency/channels.go
index a3e92c2..60fc324 100644
--- a/content/concurrency/channels.go
+++ b/content/concurrency/channels.go
@@ -4,20 +4,20 @@
import "fmt"
-func sum(a []int, c chan int) {
+func sum(s []int, c chan int) {
sum := 0
- for _, v := range a {
+ for _, v := range s {
sum += v
}
c <- sum // send sum to c
}
func main() {
- a := []int{7, 2, 8, -9, 4, 0}
+ s := []int{7, 2, 8, -9, 4, 0}
c := make(chan int)
- go sum(a[:len(a)/2], c)
- go sum(a[len(a)/2:], c)
+ go sum(s[:len(s)/2], c)
+ go sum(s[len(s)/2:], c)
x, y := <-c, <-c // receive from c
fmt.Println(x, y, x+y)