<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'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.</p>
<p>Have at me, I'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't use 'new' as a variable name, how about 'wd'</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'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't much to go on:</p>
<pre><code>unix.InotifyInit()
</code></pre>
<p>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.</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'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.</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't use 'new' as a variable name, how about 'wd'</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'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'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
- 请尽量让自己的回复能够对别人有帮助
- 支持 Markdown 格式, **粗体**、~~删除线~~、
`单行代码`
- 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
- 图片支持拖拽、截图粘贴等方式上传