Mastering-Go-Second-Edition/ch09/readClose.go
2019-03-16 08:33:03 +02:00

20 lines
281 B
Go

package main
import (
"fmt"
)
func main() {
willClose := make(chan int, 10)
// Write some data to the channel
willClose <- -1
willClose <- 0
willClose <- 2
// Empty channel
<-willClose
<-willClose
<-willClose
close(willClose)
read := <-willClose
fmt.Println(read)
}