From 14744fe82699d39b56d1acf795c7ffef38139b95 Mon Sep 17 00:00:00 2001 From: Franck Cuny Date: Sun, 10 Oct 2021 11:34:07 -0700 Subject: mpd: add function `Close` to the player Let's close both the watcher and the client, instead of leaking this interface to the user. --- tools/mpd-stats/internal/mpd/mpd.go | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'tools/mpd-stats/internal/mpd') diff --git a/tools/mpd-stats/internal/mpd/mpd.go b/tools/mpd-stats/internal/mpd/mpd.go index ed9d3c2..cebf2b2 100644 --- a/tools/mpd-stats/internal/mpd/mpd.go +++ b/tools/mpd-stats/internal/mpd/mpd.go @@ -36,3 +36,13 @@ func NewPlayer(net string, addr string) (*player, error) { return &p, nil } + +func (p *player) Close() error { + if err := p.Watcher.Close(); err != nil { + return err + } + if err := p.Client.Close(); err != nil { + return err + } + return nil +} -- cgit 1.4.1