From: Dave Cheney Date: Wed, 4 Apr 2012 10:16:21 +0000 (+1000) Subject: Add godoc example X-Git-Tag: v1.7.2~435^2~3 X-Git-Url: https://go.fuhry.dev/?a=commitdiff_plain;h=dc03e61ef12fb8b7d7b36614164f6274cb4f044d;p=fsnotify.git Add godoc example --- diff --git a/example_test.go b/example_test.go new file mode 100644 index 0000000..c8219ae --- /dev/null +++ b/example_test.go @@ -0,0 +1,20 @@ +package fsnotify_test + +func ExampleWatcher() { + watcher, err := fsnotify.NewWatcher() + if err != nil { + log.Fatal(err) + } + err = watcher.Watch("/tmp") + if err != nil { + log.Fatal(err) + } + for { + select { + case ev := <-watcher.Event: + log.Println("event:", ev) + case err := <-watcher.Error: + log.Println("error:", err) + } + } +} diff --git a/fsnotify_linux.go b/fsnotify_linux.go index 806f8ce..54abcd9 100644 --- a/fsnotify_linux.go +++ b/fsnotify_linux.go @@ -4,28 +4,7 @@ // +build linux -/* -Package fsnotify implements a wrapper for the Linux inotify system. - -Example: - watcher, err := fsotify.NewWatcher() - if err != nil { - log.Fatal(err) - } - err = watcher.Watch("/tmp") - if err != nil { - log.Fatal(err) - } - for { - select { - case ev := <-watcher.Event: - log.Println("event:", ev) - case err := <-watcher.Error: - log.Println("error:", err) - } - } - -*/ +// Package fsnotify implements a wrapper for the Linux inotify system. package fsnotify import ( @@ -52,7 +31,9 @@ func (e *FileEvent) IsDelete() bool { } // IsModify reports whether the FileEvent was triggerd by a file modification or attribute change -func (e *FileEvent) IsModify() bool { return ((e.mask & IN_MODIFY) == IN_MODIFY || (e.mask & IN_ATTRIB) == IN_ATTRIB) } +func (e *FileEvent) IsModify() bool { + return ((e.mask&IN_MODIFY) == IN_MODIFY || (e.mask&IN_ATTRIB) == IN_ATTRIB) +} // IsRename reports whether the FileEvent was triggerd by a change name func (e *FileEvent) IsRename() bool { return (e.mask & IN_MOVE_SELF) == IN_MOVE_SELF }