func Test_chanel(t *testing.T) {
c := make(chan int, 1)
go func() {
time.Sleep(time.Second * 3)
close(c)
}()
for {
select {
case i := <-c:
log.Printf("chan is closed, value is [%v]", i)
}
}
}
close的channel, 从里面可以一直取到值,不过是默认值,具体值取决于类型。