mirror of
https://github.com/DominicBreuker/pspy.git
synced 2025-12-21 03:34:50 +00:00
add tests for fswatcher package
This commit is contained in:
@@ -2,20 +2,18 @@ package fswatcher
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/dominicbreuker/pspy/internal/fswatcher/inotify"
|
||||
)
|
||||
|
||||
func parseEvents(i *inotify.Inotify, dataCh chan []byte, eventCh chan string, errCh chan error) {
|
||||
func parseEvents(i Inotify, dataCh chan []byte, eventCh chan string, errCh chan error) {
|
||||
for buf := range dataCh {
|
||||
var ptr uint32
|
||||
for len(buf[ptr:]) > 0 {
|
||||
event, size, err := i.ParseNextEvent(buf[ptr:])
|
||||
ptr += size
|
||||
if err != nil {
|
||||
errCh <- fmt.Errorf("parsing events: %v", err)
|
||||
continue
|
||||
}
|
||||
ptr += size
|
||||
eventCh <- fmt.Sprintf("%20s | %s", event.Op, event.Name)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user