Created
June 17, 2016 08:23
-
-
Save keshavab/c12956499de7b104e8e3ffb23d87cf2d to your computer and use it in GitHub Desktop.
testing nil 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" | |
| "time" | |
| ) | |
| func main() { | |
| var ch chan int | |
| go func() { | |
| for { | |
| select { | |
| case ch <- 10: | |
| fmt.Println("Send successful.") | |
| default: | |
| time.Sleep(1 * time.Second) | |
| fmt.Println("Waiting ...") | |
| } | |
| } | |
| }() | |
| time.Sleep(2 * time.Second) | |
| ch = make(chan int) | |
| time.Sleep(4 * time.Second) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment