From 7915e89e38262c3c4c02ee9a4c16253e773d16e1 Mon Sep 17 00:00:00 2001 From: Vasiliy Tolstov Date: Mon, 10 Jul 2017 23:20:56 +0300 Subject: [PATCH] fix for nil channel Signed-off-by: Vasiliy Tolstov --- server.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/server.go b/server.go index c600c28..c01c15f 100644 --- a/server.go +++ b/server.go @@ -244,7 +244,9 @@ func Serve(ctx context.Context, ln net.Listener, cfg *ServerConfig) error { handlerLoop: for _, h := range cfg.Handlers { if err := h.Handle(conn); err != nil { - cfg.ErrorCh <- err + if cfg.ErrorCh != nil { + cfg.ErrorCh <- err + } conn.Close() break handlerLoop }