From 23d1d9dd1dbfae427852ca9ccbed8e54de661268 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Paulo=20Sima=CC=83o?= Date: Thu, 7 Oct 2021 04:32:21 -0300 Subject: [PATCH] added close --- pubsub/lib.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/pubsub/lib.go b/pubsub/lib.go index 38f8773..8289dea 100644 --- a/pubsub/lib.go +++ b/pubsub/lib.go @@ -95,6 +95,15 @@ func (p *PSCli) Read(i interface{}) error { return json.Unmarshal(bs, i) } +func (p *PSCli) Close() error { + if !p.closed { + p.closed = true + close(p.ch) + return p.con.Close() + } + return nil +} + func NewCli(q string) (*PSCli, error) { ret := &PSCli{} ret.q = q