@@ -79,6 +79,7 @@ func (e Event) String() string {
79
79
return "???"
80
80
}
81
81
82
+ // Watcher describes a process that watches files for changes.
82
83
type Watcher struct {
83
84
Event chan Event
84
85
Error chan error
@@ -211,7 +212,7 @@ func (w *Watcher) list(name string) (map[string]os.FileInfo, error) {
211
212
return fileList , nil
212
213
}
213
214
214
- // Add adds either a single file or directory recursively to the file list.
215
+ // AddRecursive adds either a single file or directory recursively to the file list.
215
216
func (w * Watcher ) AddRecursive (name string ) (err error ) {
216
217
w .mu .Lock ()
217
218
defer w .mu .Unlock ()
@@ -292,7 +293,7 @@ func (w *Watcher) Remove(name string) (err error) {
292
293
return nil
293
294
}
294
295
295
- // Remove removes either a single file or a directory recursively from
296
+ // RemoveRecursive removes either a single file or a directory recursively from
296
297
// the file's list.
297
298
func (w * Watcher ) RemoveRecursive (name string ) (err error ) {
298
299
w .mu .Lock ()
@@ -346,6 +347,7 @@ func (w *Watcher) Ignore(paths ...string) (err error) {
346
347
return nil
347
348
}
348
349
350
+ // WatchedFiles retruns a map of files added to a Watcher.
349
351
func (w * Watcher ) WatchedFiles () map [string ]os.FileInfo {
350
352
w .mu .Lock ()
351
353
defer w .mu .Unlock ()
@@ -560,7 +562,7 @@ func (w *Watcher) pollEvents(files map[string]os.FileInfo, evt chan Event,
560
562
// Check for renames and moves.
561
563
for path1 , info1 := range removes {
562
564
for path2 , info2 := range creates {
563
- if SameFile (info1 , info2 ) {
565
+ if sameFile (info1 , info2 ) {
564
566
e := Event {
565
567
Op : Move ,
566
568
Path : fmt .Sprintf ("%s -> %s" , path1 , path2 ),
@@ -606,6 +608,7 @@ func (w *Watcher) Wait() {
606
608
w .wg .Wait ()
607
609
}
608
610
611
+ // Close stops a Watcher and unlocks its mutex, then sends a close signal.
609
612
func (w * Watcher ) Close () {
610
613
w .mu .Lock ()
611
614
if ! w .running {
0 commit comments