You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -18,84 +18,4 @@ We plan to include os/fsnotify in the Go standard library with a new [API](http:
18
18
* Join [golang-dev](https://groups.google.com/forum/#!forum/golang-dev) to discuss fsnotify.
19
19
* See the [Contribution Guidelines](http://golang.org/doc/contribute.html) for Go and sign the CLA.
20
20
21
-
### Example:
22
-
23
-
```go
24
-
package main
25
-
26
-
import (
27
-
"log"
28
-
29
-
"github.com/howeyc/fsnotify"
30
-
)
31
-
32
-
funcmain() {
33
-
watcher, err:= fsnotify.NewWatcher()
34
-
if err != nil {
35
-
log.Fatal(err)
36
-
}
37
-
38
-
done:=make(chanbool)
39
-
40
-
// Process events
41
-
gofunc() {
42
-
for {
43
-
select {
44
-
caseev:=<-watcher.Event:
45
-
log.Println("event:", ev)
46
-
caseerr:=<-watcher.Error:
47
-
log.Println("error:", err)
48
-
}
49
-
}
50
-
}()
51
-
52
-
err = watcher.Watch("testDir")
53
-
if err != nil {
54
-
log.Fatal(err)
55
-
}
56
-
57
-
<-done
58
-
59
-
/* ... do stuff ... */
60
-
watcher.Close()
61
-
}
62
-
```
63
-
64
-
For each event:
65
-
* Name
66
-
* IsCreate()
67
-
* IsDelete()
68
-
* IsModify()
69
-
* IsRename()
70
-
71
-
### FAQ
72
-
73
-
**When a file is moved to another directory is it still being watched?**
74
-
75
-
No (it shouldn't be, unless you are watching where it was moved to).
76
-
77
-
**When I watch a directory, are all subdirectories watched as well?**
78
-
79
-
No, you must add watches for any directory you want to watch (a recursive watcher is in the works [#56][]).
80
-
81
-
**Do I have to watch the Error and Event channels in a separate goroutine?**
82
-
83
-
As of now, yes. Looking into making this single-thread friendly (see [#7][])
84
-
85
-
**Why am I receiving multiple events for the same file on OS X?**
86
-
87
-
Spotlight indexing on OS X can result in multiple events (see [#62][]). A temporary workaround is to add your folder(s) to the *Spotlight Privacy settings* until we have a native FSEvents implementation (see [#54][]).
88
-
89
-
**How many files can be watched at once?**
90
-
91
-
There are OS-specific limits as to how many watches can be created:
92
-
* Linux: /proc/sys/fs/inotify/max_user_watches contains the limit,
93
-
reaching this limit results in a "no space left on device" error.
94
-
* BSD / OSX: sysctl variables "kern.maxfiles" and "kern.maxfilesperproc", reaching these limits results in a "too many open files" error.
0 commit comments