Force watcher type

Hi all,

Is there a simple way to force which filesystem watcher is used for events? I.e can I force kqueue to be used instead of FSEvents on MacOS?

Thanks

It looks like you should be able to build with go run build.go -tags kqueue, but it doesn’t work out of the box, the following patch makes it build:

diff --git a/lib/fs/basicfs_watch_eventtypes_kqueue.go b/lib/fs/basicfs_watch_eventtypes_kqueue.go
index c8e34dfd6..bc233cf82 100644
--- a/lib/fs/basicfs_watch_eventtypes_kqueue.go
+++ b/lib/fs/basicfs_watch_eventtypes_kqueue.go
@@ -4,8 +4,8 @@
 // License, v. 2.0. If a copy of the MPL was not distributed with this file,
 // You can obtain one at http://mozilla.org/MPL/2.0/.

-//go:build dragonfly || freebsd || netbsd || openbsd
-// +build dragonfly freebsd netbsd openbsd
+//go:build dragonfly || freebsd || netbsd || openbsd || kqueue
+// +build dragonfly freebsd netbsd openbsd kqueue

 package fs

diff --git a/lib/fs/basicfs_watch_notkqueue.go b/lib/fs/basicfs_watch_notkqueue.go
index 7d529cc27..49816156b 100644
--- a/lib/fs/basicfs_watch_notkqueue.go
+++ b/lib/fs/basicfs_watch_notkqueue.go
@@ -4,8 +4,8 @@
 // License, v. 2.0. If a copy of the MPL was not distributed with this file,
 // You can obtain one at http://mozilla.org/MPL/2.0/.

-//go:build !dragonfly && !freebsd && !netbsd && !openbsd
-// +build !dragonfly,!freebsd,!netbsd,!openbsd
+//go:build !dragonfly && !freebsd && !netbsd && !openbsd && !kqueue
+// +build !dragonfly,!freebsd,!netbsd,!openbsd,!kqueue

 package fs

Obviously, this has never been tested by anyone, but it might work.

1 Like

Amazing, thankyou!! Will give this a go.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.