[tools] WIP: implement fs notify

2 views
Skip to first unread message

Gopher Robot (Gerrit)

unread,
Jul 8, 2025, 1:48:05 PMJul 8
to Hongxiang Jiang, goph...@pubsubhelper.golang.org, golang-...@googlegroups.com, Go LUCI, Robert Findley, Madeline Kalil, golang-co...@googlegroups.com

Gopher Robot submitted the change

Unreviewed changes

25 is the latest approved patch-set.
No files were changed between the latest approved patch-set and the submitted one.

Change information

Commit message:
gopls/internal/filewatcher: introduce filewatcher using fsnotify

The file watcher is a wrapper over the fsnotify.Watcher, expose two
channels (same as fsnotify.Watcher), an events channel and an error
channel.

The file watcher automatically converted the fsnotify.Event to
protocol.FileEvent and handles some simple filtering.

- file watcher only captures events happens to *{.go, .sum, .work, .mod}.
- file watcher ignores hidden dirs and testdata.
- file watcher only pays attention to operation Rename, Remove, Create
and Write.
- file watcher have a debouncer in place that group events together and
send them in batch.

Upon "Close()", the file watcher will close the fsnotify.Watcher, close
all channels and wait for all go routine to finish.

Race analysis, file watcher only read/write mutex guarded fields in methods:
watchDir, stopWatchDir, isDir, addEvent, sendEvents, Close().

For golang/go#74292
Change-Id: I4fbaafa4bc9303d62ed60917f6199c3196f27c09
Auto-Submit: Hongxiang Jiang <hxj...@golang.org>
Reviewed-by: Robert Findley <rfin...@google.com>
Files:
  • M gopls/go.mod
  • M gopls/go.sum
  • M gopls/internal/cmd/mcp.go
  • A gopls/internal/filewatcher/filewatcher.go
  • A gopls/internal/filewatcher/filewatcher_test.go
  • M gopls/internal/licenses/licenses.go
Change size: L
Delta: 6 files changed, 677 insertions(+), 0 deletions(-)
Branch: refs/heads/master
Submit Requirements:
  • requirement satisfiedCode-Review: +2 by Robert Findley
  • requirement satisfiedTryBots-Pass: LUCI-TryBot-Result+1 by Go LUCI
Open in Gerrit
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: merged
Gerrit-Project: tools
Gerrit-Branch: master
Gerrit-Change-Id: I4fbaafa4bc9303d62ed60917f6199c3196f27c09
Gerrit-Change-Number: 684696
Gerrit-PatchSet: 27
Gerrit-Owner: Hongxiang Jiang <hxj...@golang.org>
Gerrit-Reviewer: Gopher Robot <go...@golang.org>
Gerrit-Reviewer: Hongxiang Jiang <hxj...@golang.org>
Gerrit-Reviewer: Madeline Kalil <mka...@google.com>
Gerrit-Reviewer: Robert Findley <rfin...@google.com>
open
diffy
satisfied_requirement
Reply all
Reply to author
Forward
0 new messages