File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -18,7 +18,6 @@ type FSWatcher struct {
1818 watcherList * map [string ]* watcherObj
1919 mu sync.Mutex
2020 size * uint
21- config FSWatcherConfig
2221
2322 eventCB []func (path string , event string , op string , isDir bool )
2423
@@ -55,33 +54,17 @@ type FSWatcher struct {
5554 OnAny func (path string , op string )
5655}
5756
58- // FSWatcherConfig is the configuration for the FileWatcher
59- type FSWatcherConfig struct {
60- // Init will run all On methods when the watcher starts
61- Init bool
62- }
63-
6457type watcherObj struct {
6558 watcher * fsnotify.Watcher
6659 close * bool
6760}
6861
6962// FileWatcher creates a new file watcher
70- func FileWatcher (config ... FSWatcherConfig ) * FSWatcher {
71- var cfg FSWatcherConfig
72- if len (config ) > 0 {
73- cfg = config [0 ]
74- } else {
75- cfg = FSWatcherConfig {
76- Init : false ,
77- }
78- }
79-
63+ func FileWatcher () * FSWatcher {
8064 size := uint (0 )
8165 return & FSWatcher {
8266 watcherList : & map [string ]* watcherObj {},
8367 size : & size ,
84- config : cfg ,
8568 }
8669}
8770
@@ -99,9 +82,7 @@ func (fw *FSWatcher) WatchDir(root string, nosub ...bool) error {
9982 return err
10083 }
10184
102- if fw .config .Init {
103- fw .initDir (root )
104- }
85+ fw .initDir (root )
10586
10687 runClose := false
10788
You can’t perform that action at this time.
0 commit comments