Created
December 7, 2015 07:22
-
-
Save siburu/a3f6731e6cf846f1dcb6 to your computer and use it in GitHub Desktop.
In select statement, reading from a closed channel is selected immediately without going to a default case.
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 | |
func main() { | |
ch := make(chan struct{}) | |
close(ch) | |
/* | |
for _ = range ch { | |
} | |
*/ | |
for { | |
select { | |
case <-ch: | |
default: | |
return | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment