From 5cb91165ce76de7b8a6c27057ba261547954ee77 Mon Sep 17 00:00:00 2001 From: Josh Bleecher Snyder Date: Tue, 6 Dec 2022 12:18:50 -0800 Subject: [PATCH] all: gofmt with Go 1.19 --- debug_debug.go | 1 + debug_nodebug.go | 1 + event.go | 42 +++++++++++++++++++-------------------- event_fen.go | 1 + event_fsevents.go | 1 + event_inotify.go | 1 + event_kqueue.go | 1 + event_readdcw.go | 1 + event_stub.go | 4 ++-- event_trigger.go | 1 + example_fsevents_test.go | 1 + example_inotify_test.go | 1 + example_readdcw_test.go | 1 + notify.go | 4 ++-- notify_inotify_test.go | 1 + notify_readdcw_test.go | 1 + notify_test.go | 1 + sync_readdcw_test.go | 1 + sync_unix_test.go | 1 + util_darwin_test.go | 1 + util_unix_test.go | 1 + watcher_fen.go | 1 + watcher_fen_cgo.go | 1 + watcher_fen_test.go | 1 + watcher_fsevents.go | 30 ++++++++++++++-------------- watcher_fsevents_cgo.go | 1 + watcher_fsevents_test.go | 1 + watcher_inotify.go | 1 + watcher_inotify_test.go | 1 + watcher_kqueue.go | 1 + watcher_kqueue_test.go | 1 + watcher_notimplemented.go | 4 ++-- watcher_readdcw.go | 10 ++++++---- watcher_readdcw_test.go | 1 + watcher_recursive_test.go | 1 + watcher_test.go | 1 + watcher_trigger.go | 1 + watcher_trigger_test.go | 1 + watchpoint_other.go | 1 + watchpoint_readdcw.go | 1 + 40 files changed, 82 insertions(+), 46 deletions(-) diff --git a/debug_debug.go b/debug_debug.go index 9d234ce..e641289 100644 --- a/debug_debug.go +++ b/debug_debug.go @@ -2,6 +2,7 @@ // Use of this source code is governed by the MIT license that can be // found in the LICENSE file. +//go:build debug // +build debug package notify diff --git a/debug_nodebug.go b/debug_nodebug.go index 9ebf880..724fe7a 100644 --- a/debug_nodebug.go +++ b/debug_nodebug.go @@ -2,6 +2,7 @@ // Use of this source code is governed by the MIT license that can be // found in the LICENSE file. +//go:build !debug // +build !debug package notify diff --git a/event.go b/event.go index c128841..4b4b102 100644 --- a/event.go +++ b/event.go @@ -57,54 +57,54 @@ func (e Event) String() string { // // The value of Sys if system-dependent and can be nil. // -// Sys +// # Sys // // Under Darwin (FSEvents) Sys() always returns a non-nil *notify.FSEvent value, // which is defined as: // -// type FSEvent struct { -// Path string // real path of the file or directory -// ID uint64 // ID of the event (FSEventStreamEventId) -// Flags uint32 // joint FSEvents* flags (FSEventStreamEventFlags) -// } +// type FSEvent struct { +// Path string // real path of the file or directory +// ID uint64 // ID of the event (FSEventStreamEventId) +// Flags uint32 // joint FSEvents* flags (FSEventStreamEventFlags) +// } // // For possible values of Flags see Darwin godoc for notify or FSEvents // documentation for FSEventStreamEventFlags constants: // -// https://developer.apple.com/library/mac/documentation/Darwin/Reference/FSEvents_Ref/index.html#//apple_ref/doc/constant_group/FSEventStreamEventFlags +// https://developer.apple.com/library/mac/documentation/Darwin/Reference/FSEvents_Ref/index.html#//apple_ref/doc/constant_group/FSEventStreamEventFlags // // Under Linux (inotify) Sys() always returns a non-nil *unix.InotifyEvent // value, defined as: // -// type InotifyEvent struct { -// Wd int32 // Watch descriptor -// Mask uint32 // Mask describing event -// Cookie uint32 // Unique cookie associating related events (for rename(2)) -// Len uint32 // Size of name field -// Name [0]uint8 // Optional null-terminated name -// } +// type InotifyEvent struct { +// Wd int32 // Watch descriptor +// Mask uint32 // Mask describing event +// Cookie uint32 // Unique cookie associating related events (for rename(2)) +// Len uint32 // Size of name field +// Name [0]uint8 // Optional null-terminated name +// } // // More information about inotify masks and the usage of inotify_event structure // can be found at: // -// http://man7.org/linux/man-pages/man7/inotify.7.html +// http://man7.org/linux/man-pages/man7/inotify.7.html // // Under Darwin, DragonFlyBSD, FreeBSD, NetBSD, OpenBSD (kqueue) Sys() always // returns a non-nil *notify.Kevent value, which is defined as: // -// type Kevent struct { -// Kevent *syscall.Kevent_t // Kevent is a kqueue specific structure -// FI os.FileInfo // FI describes file/dir -// } +// type Kevent struct { +// Kevent *syscall.Kevent_t // Kevent is a kqueue specific structure +// FI os.FileInfo // FI describes file/dir +// } // // More information about syscall.Kevent_t can be found at: // -// https://www.freebsd.org/cgi/man.cgi?query=kqueue +// https://www.freebsd.org/cgi/man.cgi?query=kqueue // // Under Windows (ReadDirectoryChangesW) Sys() always returns nil. The documentation // of watcher's WinAPI function can be found at: // -// https://msdn.microsoft.com/en-us/library/windows/desktop/aa365465%28v=vs.85%29.aspx +// https://msdn.microsoft.com/en-us/library/windows/desktop/aa365465%28v=vs.85%29.aspx type EventInfo interface { Event() Event // event value for the filesystem action Path() string // real path of the file or directory diff --git a/event_fen.go b/event_fen.go index 7c41ae2..1be3922 100644 --- a/event_fen.go +++ b/event_fen.go @@ -2,6 +2,7 @@ // Use of this source code is governed by the MIT license that can be // found in the LICENSE file. +//go:build solaris || illumos // +build solaris illumos package notify diff --git a/event_fsevents.go b/event_fsevents.go index 5121084..c3edfec 100644 --- a/event_fsevents.go +++ b/event_fsevents.go @@ -2,6 +2,7 @@ // Use of this source code is governed by the MIT license that can be // found in the LICENSE file. +//go:build darwin && !kqueue && cgo // +build darwin,!kqueue,cgo package notify diff --git a/event_inotify.go b/event_inotify.go index 1f32bb7..cea42ec 100644 --- a/event_inotify.go +++ b/event_inotify.go @@ -2,6 +2,7 @@ // Use of this source code is governed by the MIT license that can be // found in the LICENSE file. +//go:build linux // +build linux package notify diff --git a/event_kqueue.go b/event_kqueue.go index a71359b..8661185 100644 --- a/event_kqueue.go +++ b/event_kqueue.go @@ -2,6 +2,7 @@ // Use of this source code is governed by the MIT license that can be // found in the LICENSE file. +//go:build (darwin && kqueue) || (darwin && !cgo) || dragonfly || freebsd || netbsd || openbsd // +build darwin,kqueue darwin,!cgo dragonfly freebsd netbsd openbsd package notify diff --git a/event_readdcw.go b/event_readdcw.go index f7b82de..4ae3a06 100644 --- a/event_readdcw.go +++ b/event_readdcw.go @@ -2,6 +2,7 @@ // Use of this source code is governed by the MIT license that can be // found in the LICENSE file. +//go:build windows // +build windows package notify diff --git a/event_stub.go b/event_stub.go index dbc3bcc..68edc7e 100644 --- a/event_stub.go +++ b/event_stub.go @@ -2,8 +2,8 @@ // Use of this source code is governed by the MIT license that can be // found in the LICENSE file. -// +build !darwin,!linux,!freebsd,!dragonfly,!netbsd,!openbsd,!windows -// +build !kqueue,!solaris,!illumos +//go:build !darwin && !linux && !freebsd && !dragonfly && !netbsd && !openbsd && !windows && !kqueue && !solaris && !illumos +// +build !darwin,!linux,!freebsd,!dragonfly,!netbsd,!openbsd,!windows,!kqueue,!solaris,!illumos package notify diff --git a/event_trigger.go b/event_trigger.go index 3d2d78c..6d8cd1c 100644 --- a/event_trigger.go +++ b/event_trigger.go @@ -2,6 +2,7 @@ // Use of this source code is governed by the MIT license that can be // found in the LICENSE file. +//go:build (darwin && kqueue) || (darwin && !cgo) || dragonfly || freebsd || netbsd || openbsd || solaris || illumos // +build darwin,kqueue darwin,!cgo dragonfly freebsd netbsd openbsd solaris illumos package notify diff --git a/example_fsevents_test.go b/example_fsevents_test.go index 7713106..b0c78e8 100644 --- a/example_fsevents_test.go +++ b/example_fsevents_test.go @@ -2,6 +2,7 @@ // Use of this source code is governed by the MIT license that can be // found in the LICENSE file. +//go:build darwin && !kqueue && cgo // +build darwin,!kqueue,cgo package notify_test diff --git a/example_inotify_test.go b/example_inotify_test.go index e386012..d94a3ad 100644 --- a/example_inotify_test.go +++ b/example_inotify_test.go @@ -2,6 +2,7 @@ // Use of this source code is governed by the MIT license that can be // found in the LICENSE file. +//go:build linux // +build linux package notify_test diff --git a/example_readdcw_test.go b/example_readdcw_test.go index e9e05be..bdeb75a 100644 --- a/example_readdcw_test.go +++ b/example_readdcw_test.go @@ -2,6 +2,7 @@ // Use of this source code is governed by the MIT license that can be // found in the LICENSE file. +//go:build windows // +build windows package notify_test diff --git a/notify.go b/notify.go index faa958d..aa57660 100644 --- a/notify.go +++ b/notify.go @@ -48,12 +48,12 @@ var defaultTree = newTree() // for each path. If a single filesystem event contains multiple coalesced events, // each of them is dispatched separately. E.g. the following filesystem change: // -// ~ $ echo Hello > Notify.txt +// ~ $ echo Hello > Notify.txt // // dispatches two events - notify.Create and notify.Write. However, it may depend // on the underlying watcher implementation whether OS reports both of them. // -// Windows and recursive watches +// # Windows and recursive watches // // If a directory which path was used to create recursive watch under Windows // gets deleted, the OS will not report such event. It is advised to keep in diff --git a/notify_inotify_test.go b/notify_inotify_test.go index c5984d3..11572d9 100644 --- a/notify_inotify_test.go +++ b/notify_inotify_test.go @@ -2,6 +2,7 @@ // Use of this source code is governed by the MIT license that can be // found in the LICENSE file. +//go:build linux // +build linux package notify diff --git a/notify_readdcw_test.go b/notify_readdcw_test.go index 944b533..29484b2 100644 --- a/notify_readdcw_test.go +++ b/notify_readdcw_test.go @@ -2,6 +2,7 @@ // Use of this source code is governed by the MIT license that can be // found in the LICENSE file. +//go:build windows // +build windows package notify diff --git a/notify_test.go b/notify_test.go index 330f75f..0867925 100644 --- a/notify_test.go +++ b/notify_test.go @@ -2,6 +2,7 @@ // Use of this source code is governed by the MIT license that can be // found in the LICENSE file. +//go:build darwin || linux || freebsd || dragonfly || netbsd || openbsd || windows || solaris // +build darwin linux freebsd dragonfly netbsd openbsd windows solaris package notify diff --git a/sync_readdcw_test.go b/sync_readdcw_test.go index f299754..9b93a87 100644 --- a/sync_readdcw_test.go +++ b/sync_readdcw_test.go @@ -2,6 +2,7 @@ // Use of this source code is governed by the MIT license that can be // found in the LICENSE file. +//go:build windows // +build windows package notify diff --git a/sync_unix_test.go b/sync_unix_test.go index 5e2c5dd..8ef813e 100644 --- a/sync_unix_test.go +++ b/sync_unix_test.go @@ -2,6 +2,7 @@ // Use of this source code is governed by the MIT license that can be // found in the LICENSE file. +//go:build !windows // +build !windows package notify diff --git a/util_darwin_test.go b/util_darwin_test.go index 8c95db3..484d248 100644 --- a/util_darwin_test.go +++ b/util_darwin_test.go @@ -2,6 +2,7 @@ // Use of this source code is governed by the MIT license that can be // found in the LICENSE file. +//go:build darwin // +build darwin package notify diff --git a/util_unix_test.go b/util_unix_test.go index b944db2..2fccfc3 100644 --- a/util_unix_test.go +++ b/util_unix_test.go @@ -2,6 +2,7 @@ // Use of this source code is governed by the MIT license that can be // found in the LICENSE file. +//go:build !windows // +build !windows package notify diff --git a/watcher_fen.go b/watcher_fen.go index 31ba12f..114ec7f 100644 --- a/watcher_fen.go +++ b/watcher_fen.go @@ -2,6 +2,7 @@ // Use of this source code is governed by the MIT license that can be // found in the LICENSE file. +//go:build solaris || illumos // +build solaris illumos package notify diff --git a/watcher_fen_cgo.go b/watcher_fen_cgo.go index 47445a2..50f289d 100644 --- a/watcher_fen_cgo.go +++ b/watcher_fen_cgo.go @@ -2,6 +2,7 @@ // Use of this source code is governed by the MIT license that can be // found in the LICENSE file. +//go:build solaris || illumos // +build solaris illumos package notify diff --git a/watcher_fen_test.go b/watcher_fen_test.go index 02a5743..2ca7ec0 100644 --- a/watcher_fen_test.go +++ b/watcher_fen_test.go @@ -2,6 +2,7 @@ // Use of this source code is governed by the MIT license that can be // found in the LICENSE file. +//go:build solaris || illumos // +build solaris illumos package notify diff --git a/watcher_fsevents.go b/watcher_fsevents.go index 0627b82..dab5286 100644 --- a/watcher_fsevents.go +++ b/watcher_fsevents.go @@ -2,6 +2,7 @@ // Use of this source code is governed by the MIT license that can be // found in the LICENSE file. +//go:build darwin && !kqueue && cgo // +build darwin,!kqueue,cgo package notify @@ -55,35 +56,34 @@ type watch struct { // Example format: // -// ~ $ (trigger command) # (event set) -> (effective event set) +// ~ $ (trigger command) # (event set) -> (effective event set) // // Heuristics: // // 1. Create event is removed when it was present in previous event set. // Example: // -// ~ $ echo > file # Create|Write -> Create|Write -// ~ $ echo > file # Create|Write|InodeMetaMod -> Write|InodeMetaMod +// ~ $ echo > file # Create|Write -> Create|Write +// ~ $ echo > file # Create|Write|InodeMetaMod -> Write|InodeMetaMod // // 2. Remove event is removed if it was present in previouse event set. // Example: // -// ~ $ touch file # Create -> Create -// ~ $ rm file # Create|Remove -> Remove -// ~ $ touch file # Create|Remove -> Create +// ~ $ touch file # Create -> Create +// ~ $ rm file # Create|Remove -> Remove +// ~ $ touch file # Create|Remove -> Create // // 3. Write event is removed if not followed by InodeMetaMod on existing // file. Example: // -// ~ $ echo > file # Create|Write -> Create|Write -// ~ $ chmod +x file # Create|Write|ChangeOwner -> ChangeOwner +// ~ $ echo > file # Create|Write -> Create|Write +// ~ $ chmod +x file # Create|Write|ChangeOwner -> ChangeOwner // // 4. Write&InodeMetaMod is removed when effective event set contain Remove event. // Example: // -// ~ $ echo > file # Write|InodeMetaMod -> Write|InodeMetaMod -// ~ $ rm file # Remove|Write|InodeMetaMod -> Remove -// +// ~ $ echo > file # Write|InodeMetaMod -> Write|InodeMetaMod +// ~ $ rm file # Remove|Write|InodeMetaMod -> Remove func (w *watch) strip(base string, set uint32) uint32 { const ( write = FSEventsModified | FSEventsInodeMetaMod @@ -260,11 +260,11 @@ func (fse *fsevents) RecursiveUnwatch(path string) error { // RecursiveRewatch implements RecursiveWatcher interface. It fails: // -// * with errNotWatched when the given path is not being watched -// * with errInvalidEventSet when oldevent does not match the current event set -// * with errAlreadyWatched when watch-point given by the oldpath was meant to +// - with errNotWatched when the given path is not being watched +// - with errInvalidEventSet when oldevent does not match the current event set +// - with errAlreadyWatched when watch-point given by the oldpath was meant to // be relocated to newpath, but the newpath is already watched -// * a non-nil error when setting the watch-point with FSEvents fails +// - a non-nil error when setting the watch-point with FSEvents fails // // TODO(rjeczalik): Improve handling of watch-point relocation? See two TODOs // that follows. diff --git a/watcher_fsevents_cgo.go b/watcher_fsevents_cgo.go index 18eda55..b0b5a4a 100644 --- a/watcher_fsevents_cgo.go +++ b/watcher_fsevents_cgo.go @@ -2,6 +2,7 @@ // Use of this source code is governed by the MIT license that can be // found in the LICENSE file. +//go:build darwin && !kqueue && cgo // +build darwin,!kqueue,cgo package notify diff --git a/watcher_fsevents_test.go b/watcher_fsevents_test.go index 3a7d4da..f722fe0 100644 --- a/watcher_fsevents_test.go +++ b/watcher_fsevents_test.go @@ -2,6 +2,7 @@ // Use of this source code is governed by the MIT license that can be // found in the LICENSE file. +//go:build darwin && !kqueue && cgo // +build darwin,!kqueue,cgo package notify diff --git a/watcher_inotify.go b/watcher_inotify.go index 6045eb5..02b4328 100644 --- a/watcher_inotify.go +++ b/watcher_inotify.go @@ -2,6 +2,7 @@ // Use of this source code is governed by the MIT license that can be // found in the LICENSE file. +//go:build linux // +build linux package notify diff --git a/watcher_inotify_test.go b/watcher_inotify_test.go index 5feadaf..551f771 100644 --- a/watcher_inotify_test.go +++ b/watcher_inotify_test.go @@ -2,6 +2,7 @@ // Use of this source code is governed by the MIT license that can be // found in the LICENSE file. +//go:build linux // +build linux package notify diff --git a/watcher_kqueue.go b/watcher_kqueue.go index 96f0298..715edfb 100644 --- a/watcher_kqueue.go +++ b/watcher_kqueue.go @@ -2,6 +2,7 @@ // Use of this source code is governed by the MIT license that can be // found in the LICENSE file. +//go:build (darwin && kqueue) || (darwin && !cgo) || dragonfly || freebsd || netbsd || openbsd // +build darwin,kqueue darwin,!cgo dragonfly freebsd netbsd openbsd package notify diff --git a/watcher_kqueue_test.go b/watcher_kqueue_test.go index 3399a5e..6805df8 100644 --- a/watcher_kqueue_test.go +++ b/watcher_kqueue_test.go @@ -2,6 +2,7 @@ // Use of this source code is governed by the MIT license that can be // found in the LICENSE file. +//go:build (darwin && kqueue) || (darwin && !cgo) || dragonfly || freebsd || netbsd || openbsd // +build darwin,kqueue darwin,!cgo dragonfly freebsd netbsd openbsd package notify diff --git a/watcher_notimplemented.go b/watcher_notimplemented.go index 4213dbb..9e51766 100644 --- a/watcher_notimplemented.go +++ b/watcher_notimplemented.go @@ -2,8 +2,8 @@ // Use of this source code is governed by the MIT license that can be // found in the LICENSE file. -// +build !darwin,!linux,!freebsd,!dragonfly,!netbsd,!openbsd,!windows -// +build !kqueue,!solaris,!illumos +//go:build !darwin && !linux && !freebsd && !dragonfly && !netbsd && !openbsd && !windows && !kqueue && !solaris && !illumos +// +build !darwin,!linux,!freebsd,!dragonfly,!netbsd,!openbsd,!windows,!kqueue,!solaris,!illumos package notify diff --git a/watcher_readdcw.go b/watcher_readdcw.go index 93d68df..b0dee41 100644 --- a/watcher_readdcw.go +++ b/watcher_readdcw.go @@ -2,6 +2,7 @@ // Use of this source code is governed by the MIT license that can be // found in the LICENSE file. +//go:build windows // +build windows package notify @@ -32,10 +33,11 @@ const ( ) // Filter used in current implementation was split into four segments: -// - bits 0-11 store ReadDirectoryChangesW filters, -// - bits 12-19 store File notify actions, -// - bits 20-27 store notify specific events and flags, -// - bits 28-31 store states which are used in loop's FSM. +// - bits 0-11 store ReadDirectoryChangesW filters, +// - bits 12-19 store File notify actions, +// - bits 20-27 store notify specific events and flags, +// - bits 28-31 store states which are used in loop's FSM. +// // Constants below are used as masks to retrieve only specific filter parts. const ( onlyNotifyChanges uint32 = 0x00000FFF diff --git a/watcher_readdcw_test.go b/watcher_readdcw_test.go index ea15b4a..488ec3e 100644 --- a/watcher_readdcw_test.go +++ b/watcher_readdcw_test.go @@ -2,6 +2,7 @@ // Use of this source code is governed by the MIT license that can be // found in the LICENSE file. +//go:build windows // +build windows package notify diff --git a/watcher_recursive_test.go b/watcher_recursive_test.go index ede01e6..752fc5a 100644 --- a/watcher_recursive_test.go +++ b/watcher_recursive_test.go @@ -2,6 +2,7 @@ // Use of this source code is governed by the MIT license that can be // found in the LICENSE file. +//go:build (darwin && !kqueue && cgo) || windows // +build darwin,!kqueue,cgo windows package notify diff --git a/watcher_test.go b/watcher_test.go index fd33d23..6cab6d7 100644 --- a/watcher_test.go +++ b/watcher_test.go @@ -2,6 +2,7 @@ // Use of this source code is governed by the MIT license that can be // found in the LICENSE file. +//go:build darwin || linux || freebsd || dragonfly || netbsd || openbsd || windows || solaris // +build darwin linux freebsd dragonfly netbsd openbsd windows solaris package notify diff --git a/watcher_trigger.go b/watcher_trigger.go index 03efc40..7cd0824 100644 --- a/watcher_trigger.go +++ b/watcher_trigger.go @@ -2,6 +2,7 @@ // Use of this source code is governed by the MIT license that can be // found in the LICENSE file. +//go:build (darwin && kqueue) || (darwin && !cgo) || dragonfly || freebsd || netbsd || openbsd || solaris || illumos // +build darwin,kqueue darwin,!cgo dragonfly freebsd netbsd openbsd solaris illumos // watcher_trigger is used for FEN and kqueue which behave similarly: diff --git a/watcher_trigger_test.go b/watcher_trigger_test.go index 4054237..e94fffd 100644 --- a/watcher_trigger_test.go +++ b/watcher_trigger_test.go @@ -2,6 +2,7 @@ // Use of this source code is governed by the MIT license that can be // found in the LICENSE file. +//go:build (darwin && kqueue) || (darwin && !cgo) || dragonfly || freebsd || netbsd || openbsd || solaris || illumos // +build darwin,kqueue darwin,!cgo dragonfly freebsd netbsd openbsd solaris illumos package notify diff --git a/watchpoint_other.go b/watchpoint_other.go index 9bb381d..d426999 100644 --- a/watchpoint_other.go +++ b/watchpoint_other.go @@ -2,6 +2,7 @@ // Use of this source code is governed by the MIT license that can be // found in the LICENSE file. +//go:build !windows // +build !windows package notify diff --git a/watchpoint_readdcw.go b/watchpoint_readdcw.go index 9fd1e1d..49a9b9c 100644 --- a/watchpoint_readdcw.go +++ b/watchpoint_readdcw.go @@ -2,6 +2,7 @@ // Use of this source code is governed by the MIT license that can be // found in the LICENSE file. +//go:build windows // +build windows package notify