From ca8613745fcc194edac5a8d871af69e9861ce15e Mon Sep 17 00:00:00 2001 From: "Alexander \"Arav\" Andreev" Date: Tue, 7 Feb 2023 02:31:30 +0400 Subject: [PATCH] First check if a unix socket used and only then defer a removing of it. --- cmd/dwelling-radio/main.go | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/cmd/dwelling-radio/main.go b/cmd/dwelling-radio/main.go index 6634e8a..48298f2 100644 --- a/cmd/dwelling-radio/main.go +++ b/cmd/dwelling-radio/main.go @@ -34,15 +34,10 @@ func main() { log.Fatalln(err) } + if typ, addr := config.SplitNetworkAddress(); typ == "unix" { + defer os.Remove(addr) } - defer func() { - if typ, addr := config.SplitNetworkAddress(); typ == "unix" { - os.Remove(addr) - } - }() - - playlistWatcher := radio.NewPlaylistLogWatcher() if err := playlistWatcher.Watch(config.Icecast.Playlist, config.ListLastNSongs); err != nil { log.Fatalln(err)