diff --git a/ch09/readClose.go b/ch09/readClose.go new file mode 100644 index 0000000..2159600 --- /dev/null +++ b/ch09/readClose.go @@ -0,0 +1,20 @@ +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) +}