Closing channels
ch <- 1
ch <- 2
ch <- 3
close(ch) // Closes a channel
// Iterate the channel until closed
for i := range ch {
···
}
// Closed if `ok == false`
v, ok := <- ch
See: Range and close
Comments
ch <- 1
ch <- 2
ch <- 3
close(ch) // Closes a channel
// Iterate the channel until closed
for i := range ch {
···
}
// Closed if `ok == false`
v, ok := <- ch
See: Range and close