Skip to content

Commit

Permalink
Document that Watcher.Remove returns nil if the Watcher is closed
Browse files Browse the repository at this point in the history
This was already tested in TestClose/error_after_closed; just wasn't
documented.
  • Loading branch information
arp242 committed Nov 16, 2022
1 parent 131ec3d commit a62540a
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 0 deletions.
2 changes: 2 additions & 0 deletions backend_fen.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,8 @@ func (w *Watcher) AddWith(name string, opts ...addOpt) error {
// /tmp/dir and /tmp/dir/subdir then you will need to remove both.
//
// Removing a path that has not yet been added returns [ErrNonExistentWatch].
//
// Returns nil if [Watcher.Close] was called.
func (w *Watcher) Remove(name string) error {
if w.isClosed() {
return nil
Expand Down
2 changes: 2 additions & 0 deletions backend_inotify.go
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,8 @@ func (w *Watcher) AddWith(name string, opts ...addOpt) error {
// /tmp/dir and /tmp/dir/subdir then you will need to remove both.
//
// Removing a path that has not yet been added returns [ErrNonExistentWatch].
//
// Returns nil if [Watcher.Close] was called.
func (w *Watcher) Remove(name string) error {
if w.isClosed() {
return nil
Expand Down
2 changes: 2 additions & 0 deletions backend_kqueue.go
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,8 @@ func (w *Watcher) AddWith(name string, opts ...addOpt) error {
// /tmp/dir and /tmp/dir/subdir then you will need to remove both.
//
// Removing a path that has not yet been added returns [ErrNonExistentWatch].
//
// Returns nil if [Watcher.Close] was called.
func (w *Watcher) Remove(name string) error {
return w.remove(name, true)
}
Expand Down
2 changes: 2 additions & 0 deletions backend_other.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,4 +166,6 @@ func (w *Watcher) AddWith(name string, opts ...addOpt) error { return nil }
// /tmp/dir and /tmp/dir/subdir then you will need to remove both.
//
// Removing a path that has not yet been added returns [ErrNonExistentWatch].
//
// Returns nil if [Watcher.Close] was called.
func (w *Watcher) Remove(name string) error { return nil }
2 changes: 2 additions & 0 deletions backend_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,8 @@ func (w *Watcher) AddWith(name string, opts ...addOpt) error {
// /tmp/dir and /tmp/dir/subdir then you will need to remove both.
//
// Removing a path that has not yet been added returns [ErrNonExistentWatch].
//
// Returns nil if [Watcher.Close] was called.
func (w *Watcher) Remove(name string) error {
if w.isClosed() {
return nil
Expand Down
2 changes: 2 additions & 0 deletions mkdoc.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ remove=$(<<EOF
// /tmp/dir and /tmp/dir/subdir then you will need to remove both.
//
// Removing a path that has not yet been added returns [ErrNonExistentWatch].
//
// Returns nil if [Watcher.Close] was called.
EOF
)

Expand Down

0 comments on commit a62540a

Please sign in to comment.