go-fsevents - Request for comments/suggestions/review

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

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

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