From 6f01605d382ef4d570a52aeab83837dd20dfbe09 Mon Sep 17 00:00:00 2001 From: Adrian Zankich Date: Wed, 18 Dec 2013 12:54:08 -0800 Subject: [PATCH] DRY up On function --- utils.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/utils.go b/utils.go index c9316dd3d..e0c1cfc20 100644 --- a/utils.go +++ b/utils.go @@ -44,11 +44,12 @@ func Rand(max int) int { return rand.Intn(max) } -func On(cs chan interface{}) interface{} { - for s := range cs { - return s - } - return nil +func On(cs chan interface{}, f func(s interface{})) { + go func() { + for s := range cs { + f(s) + } + }() } func ConnectToTcp(port string) io.ReadWriteCloser {