1 // Copyright (c) 2014-2015 The Notify Authors. All rights reserved.
2 // Use of this source code is governed by the MIT license that can be
3 // found in the LICENSE file.
12 "github.com/rjeczalik/notify"
15 // This example shows how to watch directory-name changes in the working directory subtree.
16 func ExampleWatch_windows() {
17 // Make the channel buffered to ensure no event is dropped. Notify will drop
18 // an event if the receiver is not able to keep up the sending pace.
19 c := make(chan notify.EventInfo, 4)
21 // Since notify package behaves exactly like ReadDirectoryChangesW function,
22 // we must register notify.FileNotifyChangeDirName filter and wait for one
23 // of FileAction* events.
24 if err := notify.Watch("./...", c, notify.FileNotifyChangeDirName); err != nil {
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")