go-fsevents - Request for comments/suggestions/review

blov · 2017-03-07 17:00:09 · 621 次点击    
这是一个分享于 2017-03-07 17:00:09 的资源,其中的信息可能已经有所发展或是发生改变。

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:

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.

tywkeene:

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.


入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889

621 次点击  
加入收藏 微博
0 回复
暂无回复
添加一条新回复 (您需要 登录 后才能回复 没有账号 ?)
  • 请尽量让自己的回复能够对别人有帮助
  • 支持 Markdown 格式, **粗体**、~~删除线~~、`单行代码`
  • 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
  • 图片支持拖拽、截图粘贴等方式上传