Created
November 28, 2016 16:08
-
-
Save gonzaloserrano/11915f6a8e7b27ed62fb0b807fda5072 to your computer and use it in GitHub Desktop.
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 ( | |
"time" | |
"github.com/socialpoint/sprocket/pkg/dumper" | |
) | |
func main() { | |
c := make(chan struct{}) | |
delay := 2 * time.Second | |
go func() { | |
time.Sleep(delay / 2) | |
//c <- struct{}{} | |
println("closing...") | |
close(c) | |
}() | |
ticker := time.NewTicker(time.Second) | |
select { | |
case msg, ok := <-c: | |
dumper.Y(msg, ok) | |
case <-ticker.C: | |
dumper.R("fail") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment