A send to a nil channel blocks forever A receive from a nil channel blocks forever
A send to a closed channel panics A receive from a closed channel returns the zero value immediately
// For Reader
v, ok := <- c
if ok {
fmt.Println("not closed")
}
// For Writer?
// You can't do anything.. :<
// But the rule of thumb is that only writer should close channel. So as writer, you shouldn't need to check if a channel is // closed ever as you should know the answer ..
c := make(chan int)
close(c)
close(c) // panic!
fmt.Println("Hello, playground", c)package main
import (
"fmt"
)
func main() {
var c chan int
close(c) // panic!
fmt.Println("Hello, playground", c)
}