From 5c45b0e3e5fbe479155ad403b4936d2485a028bd Mon Sep 17 00:00:00 2001 From: Kevin Chabowski Date: Thu, 27 Mar 2014 21:36:19 +0100 Subject: Stopping the ticker in Push --- chat/buddy.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/chat/buddy.go b/chat/buddy.go index 5b2308c..d369c61 100644 --- a/chat/buddy.go +++ b/chat/buddy.go @@ -28,9 +28,11 @@ func (b *Buddy) Leave() { // Push pushes a message to the buddies Receive channel func (b *Buddy) Push(msg Message) { go func() { + t := time.NewTicker(time.Millisecond * 100) + defer t.Stop() select { case b.Receive <- msg: - case <-time.Tick(time.Millisecond * 100): + case <-t.C: } }() } -- cgit v1.2.3-70-g09d2