From 227dc816fa69bb2c39069779963b8d610d91aaf9 Mon Sep 17 00:00:00 2001 From: surdeus Date: Thu, 28 Sep 2023 08:15:57 +0300 Subject: [PATCH] Should think of getting rid of race conditions, for now just recover() . --- tg/update.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tg/update.go b/tg/update.go index 60439da..1fc2c29 100644 --- a/tg/update.go +++ b/tg/update.go @@ -20,6 +20,7 @@ func (updates *UpdateChan) Chan() chan *Update { // Send an update to the channel. // Returns true if the update was sent. func (updates *UpdateChan) Send(u *Update) bool { + defer recover() if updates == nil || updates.chn == nil { return false } @@ -45,7 +46,8 @@ func (updates *UpdateChan) Close() { if updates == nil || updates.chn == nil { return } - close(updates.chn) + chn := updates.chn updates.chn = nil + close(chn) }