From da001dbe397eda4b4d2f63e13108897f46e61f5c Mon Sep 17 00:00:00 2001 From: "Alexander \"Arav\" Andreev" Date: Fri, 26 May 2023 17:21:13 +0400 Subject: [PATCH] To decrease nesting go directive was removed. --- pkg/watcher/linux.go | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/pkg/watcher/linux.go b/pkg/watcher/linux.go index fd8395e..095a260 100644 --- a/pkg/watcher/linux.go +++ b/pkg/watcher/linux.go @@ -54,26 +54,24 @@ func (w *InotifyWatcher) AddWatch(path string, mask uint32) error { // WatchForMask checks for events specified in `mask` and sends them // to channel `fired`. See `man inotify` for events. func (w *InotifyWatcher) WatchForMask(fired chan uint32, mask uint32) { - go func() { - for !w.closed { - buffer := make([]byte, syscall.SizeofInotifyEvent*inotifyCount) - n, err := syscall.Read(w.fd, buffer) - if err != nil { - break - } + for !w.closed { + buffer := make([]byte, syscall.SizeofInotifyEvent*inotifyCount) + n, err := syscall.Read(w.fd, buffer) + if err != nil { + break + } - if n < syscall.SizeofInotifyEvent { - continue - } + if n < syscall.SizeofInotifyEvent { + continue + } - for offset := 0; offset < len(buffer); offset += syscall.SizeofInotifyEvent { - event := (*syscall.InotifyEvent)(unsafe.Pointer(&buffer[offset])) - if event.Mask&mask > 0 { - fired <- event.Mask - } + for offset := 0; offset < len(buffer); offset += syscall.SizeofInotifyEvent { + event := (*syscall.InotifyEvent)(unsafe.Pointer(&buffer[offset])) + if event.Mask&mask > 0 { + fired <- event.Mask } } - }() + } } // Close removes all watchers, closes inotify descriptor and stops all