]> go.fuhry.dev Git - fsnotify.git/commitdiff
Bring example file back.
authorChris Howey <chris@howey.me>
Tue, 3 Jul 2012 00:56:53 +0000 (19:56 -0500)
committerChris Howey <chris@howey.me>
Tue, 3 Jul 2012 00:56:53 +0000 (19:56 -0500)
example_test.go [new file with mode: 0644]

diff --git a/example_test.go b/example_test.go
new file mode 100644 (file)
index 0000000..5f0c8b5
--- /dev/null
@@ -0,0 +1,29 @@
+package fsnotify_test
+
+import (
+       "github.com/howeyc/fsnotify"
+       "log"
+)
+
+func ExampleNewWatcher() {
+       watcher, err := fsnotify.NewWatcher()
+       if err != nil {
+               log.Fatal(err)
+       }
+
+       go func() {
+               for {
+                       select {
+                       case ev := <-watcher.Event:
+                               log.Println("event:", ev)
+                       case err := <-watcher.Error:
+                               log.Println("error:", err)
+                       }
+               }
+       }()
+
+       err = watcher.Watch("/tmp/foo")
+       if err != nil {
+               log.Fatal(err)
+       }
+}