func closeChan() {
command := make(chan bool, 5)
command <- true
command <- true
command <- true
command <- true
close(command)
fmt.Printf("close chan has finished\n")
for i := 0; i < 10; i++ {
fmt.Printf("from a closed chan:%v\n", <-command)
/**
close chan has finished
from a closed chan:true
from a closed chan:true
from a closed chan:true
from a closed chan:true
from a closed chan:false
from a closed chan:false
from a closed chan:false
from a closed chan:false
from a closed chan:false
from a closed chan:false
*/
}
}
Conclusion:
After reading the existing data in chan, it will be the dafualt value