https://github.com/tywkeene/go-fsevents
Writing this because I want filesystem event monitoring that just works, and works recursively, automatically, so I can get on with my day.
Main goals:
Recursive watching
Automatically add watches for new directories that are created under the watch root
Adding and removing watches on the fly
Custom events (e.g IN_CREATE | IN_MOVED_TO | IN_ISDIR = Directory created) for simplicity
Would appreciate some feedback, I'm sure I've done something wrong so far, and my code at the moment probably isn't the best but I've just about run out of steam, since this is a side project meant to be used in another of my projects.
Have at me, I'm ready.
Cheers, gophers.
Edit: spelling
评论:
allhatenocattle:
tywkeene:https://github.com/tywkeene/go-fsevents/blob/master/fsevents.go#L130
why return an error type when it is always nil
The logic is gnarly around https://github.com/tywkeene/go-fsevents/blob/master/fsevents.go#L210 consider putting it into a separate function
https://github.com/tywkeene/go-fsevents/blob/master/fsevents.go#L105 I wouldn't use 'new' as a variable name, how about 'wd'
https://github.com/tywkeene/go-fsevents/blob/master/fsevents.go#L69 I wouldn't have the error messages start with capital letters, the user will usually be appending them to their output and it would look odd.
Hi! Thanks for taking the time to give it a look.
https://github.com/tywkeene/go-fsevents/blob/master/fsevents.go#L130 why return an error type when it is always nil
As far as I can tell, and there isn't much to go on:
unix.InotifyInit()
Can return an error, so I'm going by that. There isn't much documentation in the unix package, so unless there's something you know that I don't, it needs to return an error. Otherwise you'd be right, just return the struct.
The logic is gnarly around https://github.com/tywkeene/go-fsevents/blob/master/fsevents.go#L210 consider putting it into a separate function
Yep, definitely. I copied most of this from here since I didn't feel like taking the time to bash my head against it. I'll be going back through and cleaning that up, as well as some other things.
https://github.com/tywkeene/go-fsevents/blob/master/fsevents.go#L105 I wouldn't use 'new' as a variable name, how about 'wd'
Fair enough.
https://github.com/tywkeene/go-fsevents/blob/master/fsevents.go#L69 I wouldn't have the error messages start with capital letters, the user will usually be appending them to their output and it would look odd.
Didn't even think about that, another fair point.
Again thanks for the input, hopefully I can get this to a stable point and be able to offer it to the community.
Cheers.
