Skip to content

Instantly share code, notes, and snippets.

@gonzaloserrano
Created November 28, 2016 16:08
Show Gist options
  • Save gonzaloserrano/11915f6a8e7b27ed62fb0b807fda5072 to your computer and use it in GitHub Desktop.
Save gonzaloserrano/11915f6a8e7b27ed62fb0b807fda5072 to your computer and use it in GitHub Desktop.
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