Created
June 14, 2019 04:58
-
-
Save fengyfei/67f777483169a23527af581a2ba12558 to your computer and use it in GitHub Desktop.
[Go][Channel] Read from closed Channel
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
) | |
func main() { | |
ch := make(chan int) | |
close(ch) | |
for i := 0; i < 10; i++ { | |
select { | |
case <-ch: | |
fmt.Println("Read from closed channel") | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment