()
| 62 | } |
| 63 | |
| 64 | func (w *Watcher) Start() { |
| 65 | w.mutex.Lock() |
| 66 | defer w.mutex.Unlock() |
| 67 | |
| 68 | log.Printf("starting file watcher\n") |
| 69 | w.initialized = true |
| 70 | w.sendInitialValues() |
| 71 | |
| 72 | go func() { |
| 73 | defer func() { |
| 74 | panichandler.PanicHandler("filewatcher:Start", recover()) |
| 75 | }() |
| 76 | for { |
| 77 | select { |
| 78 | case event, ok := <-w.watcher.Events: |
| 79 | if !ok { |
| 80 | return |
| 81 | } |
| 82 | w.handleEvent(event) |
| 83 | case err, ok := <-w.watcher.Errors: |
| 84 | if !ok { |
| 85 | return |
| 86 | } |
| 87 | log.Println("watcher error:", err) |
| 88 | } |
| 89 | } |
| 90 | }() |
| 91 | } |
| 92 | |
| 93 | // for initial values, exit on first error |
| 94 | func (w *Watcher) sendInitialValues() error { |
nothing calls this directly
no test coverage detected