10.4.3 值为nil的通道
package main
import (
"fmt"
"math/rand"
"time"
)func add(c chan int) {
sum := 0
t := time.NewTimer(time.Second)
for {
select {
case input := <-c:
sum = sum + input
case <-t.C:
c = nil
fmt.Println(sum)
}
}
}Last updated