| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
package notify_test |
| 8 |
|
| 9 |
import ( |
| 10 |
"log" |
| 11 |
|
| 12 |
"github.com/syncthing/notify" |
| 13 |
) |
| 14 |
|
| 15 |
|
| 16 |
func ExampleWatch_windows() { |
| 17 |
|
| 18 |
|
| 19 |
c := make(chan notify.EventInfo, 4) |
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
if err := notify.Watch("./...", c, notify.FileNotifyChangeDirName); err != nil { |
| 25 |
log.Fatal(err) |
| 26 |
} |
| 27 |
defer notify.Stop(c) |
| 28 |
|
| 29 |
|
| 30 |
for ei := range c { |
| 31 |
switch ei.Event() { |
| 32 |
case notify.FileActionAdded, notify.FileActionRenamedNewName: |
| 33 |
log.Println("Created:", ei.Path()) |
| 34 |
case notify.FileActionRemoved, notify.FileActionRenamedOldName: |
| 35 |
log.Println("Removed:", ei.Path()) |
| 36 |
case notify.FileActionModified: |
| 37 |
panic("notify: unexpected action") |
| 38 |
} |
| 39 |
} |
| 40 |
} |