From c545152fa157e52f9ac5ebf2e58fdc1a254faf91 Mon Sep 17 00:00:00 2001 From: Eugene Burkov Date: Fri, 14 Jun 2024 14:57:01 +0300 Subject: [PATCH] all: imp code --- internal/aghnet/hostscontainer.go | 3 ++- internal/aghos/fswatcher.go | 12 ++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/internal/aghnet/hostscontainer.go b/internal/aghnet/hostscontainer.go index b8e86448..9390ac45 100644 --- a/internal/aghnet/hostscontainer.go +++ b/internal/aghnet/hostscontainer.go @@ -161,7 +161,8 @@ func (hc *HostsContainer) handleEvents() { defer close(hc.updates) - ok, eventsCh := true, hc.watcher.Events() + eventsCh := hc.watcher.Events() + ok := eventsCh != nil for ok { select { case _, ok = <-eventsCh: diff --git a/internal/aghos/fswatcher.go b/internal/aghos/fswatcher.go index 5cb1b1c5..de95e94c 100644 --- a/internal/aghos/fswatcher.go +++ b/internal/aghos/fswatcher.go @@ -168,22 +168,26 @@ type EmptyFSWatcher struct{} // type check var _ FSWatcher = EmptyFSWatcher{} -// Start implements the [FSWatcher] interface for EmptyFSWatcher. +// Start implements the [FSWatcher] interface for EmptyFSWatcher. It always +// returns nil error. func (EmptyFSWatcher) Start() (err error) { return nil } -// Close implements the [FSWatcher] interface for EmptyFSWatcher. +// Close implements the [FSWatcher] interface for EmptyFSWatcher. It always +// returns nil error. func (EmptyFSWatcher) Close() (err error) { return nil } -// Events implements the [FSWatcher] interface for EmptyFSWatcher. +// Events implements the [FSWatcher] interface for EmptyFSWatcher. It always +// returns nil channel. func (EmptyFSWatcher) Events() (e <-chan event) { return nil } -// Add implements the [FSWatcher] interface for EmptyFSWatcher. +// Add implements the [FSWatcher] interface for EmptyFSWatcher. It always +// returns nil error. func (EmptyFSWatcher) Add(_ string) (err error) { return nil }