From 1a4e092e987843a825b29733a430e12e4ef896d7 Mon Sep 17 00:00:00 2001 From: Nathan Youngman Date: Fri, 4 Jul 2014 21:03:05 -0600 Subject: [PATCH] update example --- README.md | 3 +++ example_test.go | 8 ++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index c52e6d5..f8e0c96 100644 --- a/README.md +++ b/README.md @@ -26,3 +26,6 @@ A future version of Go will have [fsnotify in the standard library](https://code Please read [CONTRIBUTING](https://github.com/fsnotify/fsnotify/blob/master/CONTRIBUTING.md) before opening a pull request. +## Example + +See [example_test.go](https://github.com/fsnotify/fsnotify/blob/master/example_test.go). diff --git a/example_test.go b/example_test.go index 5b420cc..75261fb 100644 --- a/example_test.go +++ b/example_test.go @@ -17,12 +17,16 @@ func ExampleNewWatcher() { if err != nil { log.Fatal(err) } + defer watcher.Close() go func() { for { select { - case ev := <-watcher.Events: - log.Println("event:", ev) + case event := <-watcher.Events: + log.Println("event:", event) + if event.Op&fsnotify.Write == fsnotify.Write { + log.Println("modified file:", event.Name) + } case err := <-watcher.Errors: log.Println("error:", err) } -- 2.50.1