@@ -14,7 +14,7 @@ import (
1414 "golang.org/x/sys/unix"
1515)
1616
17- // Watcher watches a set of files , delivering events to a channel.
17+ // Watcher watches a set of paths , delivering events on a channel.
1818//
1919// A watcher should not be copied (e.g. pass it by pointer, rather than by
2020// value).
@@ -28,6 +28,8 @@ import (
2828// os.Remove("file") // Triggers Chmod
2929// fp.Close() // Triggers Remove
3030//
31+ // This is the event that inotify sends, so not much can be changed about this.
32+ //
3133// The fs.inotify.max_user_watches sysctl variable specifies the upper limit
3234// for the number of watches per user, and fs.inotify.max_user_instances
3335// specifies the maximum number of inotify instances per user. Every Watcher you
@@ -43,7 +45,8 @@ import (
4345// sysctl fs.inotify.max_user_instances=128
4446//
4547// To make the changes persist on reboot edit /etc/sysctl.conf or
46- // /usr/lib/sysctl.d/50-default.conf (on some systemd systems):
48+ // /usr/lib/sysctl.d/50-default.conf (details differ per Linux distro; check
49+ // your distro's documentation):
4750//
4851// fs.inotify.max_user_watches=124983
4952// fs.inotify.max_user_instances=128
@@ -74,7 +77,7 @@ type Watcher struct {
7477 // Events sends the filesystem change events.
7578 //
7679 // fsnotify can send the following events; a "path" here can refer to a
77- // file, directory, symbolic link, or special files like a FIFO.
80+ // file, directory, symbolic link, or special file like a FIFO.
7881 //
7982 // fsnotify.Create A new path was created; this may be followed by one
8083 // or more Write events if data also gets written to a
@@ -83,7 +86,7 @@ type Watcher struct {
8386 // fsnotify.Remove A path was removed.
8487 //
8588 // fsnotify.Rename A path was renamed. A rename is always sent with the
86- // old path as [ Event.Name] , and a Create event will be
89+ // old path as Event.Name, and a Create event will be
8790 // sent with the new name. Renames are only sent for
8891 // paths that are currently watched; e.g. moving an
8992 // unmonitored file into a monitored directory will
@@ -100,10 +103,11 @@ type Watcher struct {
100103 // probably want to wait until you've stopped receiving
101104 // them (see the dedup example in cmd/fsnotify).
102105 //
103- // fsnotify.Chmod Attributes were changes (never sent on Windows). On
104- // Linux this is also sent when a file is removed (or
105- // more accurately, when a link to an inode is
106- // removed), and on kqueue when a file is truncated.
106+ // fsnotify.Chmod Attributes were changed. On Linux this is also sent
107+ // when a file is removed (or more accurately, when a
108+ // link to an inode is removed). On kqueue it's sent
109+ // and on kqueue when a file is truncated. On Windows
110+ // it's never sent.
107111 Events chan Event
108112
109113 // Errors sends any errors.
@@ -241,7 +245,7 @@ func (w *Watcher) Close() error {
241245//
242246// A path will remain watched if it gets renamed to somewhere else on the same
243247// filesystem, but the monitor will get removed if the path gets deleted and
244- // re-created.
248+ // re-created, or if it's moved to a different filesystem .
245249//
246250// Notifications on network filesystems (NFS, SMB, FUSE, etc.) or special
247251// filesystems (/proc, /sys, etc.) generally don't work.
@@ -257,12 +261,12 @@ func (w *Watcher) Close() error {
257261// Watching individual files (rather than directories) is generally not
258262// recommended as many tools update files atomically. Instead of "just" writing
259263// to the file a temporary file will be written to first, and if successful the
260- // temporary file is moved to to destination, removing the original, or some
264+ // temporary file is moved to to destination removing the original, or some
261265// variant thereof. The watcher on the original file is now lost, as it no
262266// longer exists.
263267//
264- // Instead, watch the parent directory and use [ Event.Name] to filter out files
265- // you're not interested in. There is an example of this in cmd/fsnotify/file.go
268+ // Instead, watch the parent directory and use Event.Name to filter out files
269+ // you're not interested in. There is an example of this in [ cmd/fsnotify/file.go].
266270func (w * Watcher ) Add (name string ) error {
267271 w .mu .Lock ()
268272 w .userWatches [name ] = struct {}{}
@@ -332,7 +336,7 @@ func (w *Watcher) Remove(name string) error {
332336 return nil
333337}
334338
335- // WatchList returns all paths added with Add() (and are not yet removed).
339+ // WatchList returns all paths added with [ Add] (and are not yet removed).
336340func (w * Watcher ) WatchList () []string {
337341 w .mu .Lock ()
338342 defer w .mu .Unlock ()
0 commit comments