[tools] gopls/internal/filewatcher: add watcher interface

0 views
Skip to first unread message

Gopher Robot (Gerrit)

unread,
Mar 17, 2026, 2:16:27 PM (yesterday) Mar 17
to Hongxiang Jiang, goph...@pubsubhelper.golang.org, golang-...@googlegroups.com, Go LUCI, Alan Donovan, golang-co...@googlegroups.com

Gopher Robot submitted the change with unreviewed changes

Unreviewed changes

1 is the latest approved patch-set.
The change was submitted with unreviewed changes in the following files:

```
The name of the file: gopls/internal/filewatcher/filewatcher.go
Insertions: 2, Deletions: 0.

@@ -31,6 +31,8 @@
// The provided event handler is called sequentially with a batch of file events,
// but the error handler is called concurrently. The watcher blocks until the
// handler returns, so the handlers should be fast and non-blocking.
+//
+// TODO(hxjiang): replace mode string to enum.
func New(mode string, interval time.Duration, logger *slog.Logger, onEvents func([]protocol.FileEvent), onError func(error)) (Watcher, error) {
switch mode {
// TODO (hxjiang): support poll watcher.
```
```
The name of the file: gopls/internal/filewatcher/fsnotify_watcher.go
Insertions: 2, Deletions: 0.

@@ -7,6 +7,7 @@
import (
"errors"
"io/fs"
+ "log"
"log/slog"
"os"
"path/filepath"
@@ -292,6 +293,7 @@
// WatchDir walks through the directory and all its subdirectories, adding
// them to the watcher.
func (w *fsnotifyWatcher) WatchDir(path string) error {
+ log.Printf("Watching %s", path)
return filepath.WalkDir(filepath.Clean(path), func(path string, d fs.DirEntry, err error) error {
if d.IsDir() {
if skipDir(d.Name()) {
```

Change information

Commit message:
gopls/internal/filewatcher: add watcher interface

This change introduces a Watcher interface to allow for alternative
file-watching implementations (e.g., a git status-like scanner).
The existing fsnotify-based implementation is renamed to fsnotifyWatcher.

For golang/go#77814 golang/go#76291
Change-Id: I73e2c2526bb8accec18caef17c051211b026830b
Auto-Submit: Hongxiang Jiang <hxj...@golang.org>
Reviewed-by: Alan Donovan <adon...@google.com>
Files:
  • M gopls/internal/cmd/mcp.go
  • M gopls/internal/filewatcher/filewatcher.go
  • M gopls/internal/filewatcher/filewatcher_test.go
  • A gopls/internal/filewatcher/fsnotify_watcher.go
Change size: XL
Delta: 4 files changed, 566 insertions(+), 519 deletions(-)
Branch: refs/heads/master
Submit Requirements:
  • requirement satisfiedCode-Review: +2 by Alan Donovan
  • 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: I73e2c2526bb8accec18caef17c051211b026830b
Gerrit-Change-Number: 756020
Gerrit-PatchSet: 5
Gerrit-Owner: Hongxiang Jiang <hxj...@golang.org>
Gerrit-Reviewer: Alan Donovan <adon...@google.com>
Gerrit-Reviewer: Gopher Robot <go...@golang.org>
Gerrit-Reviewer: Hongxiang Jiang <hxj...@golang.org>
open
diffy
satisfied_requirement
Reply all
Reply to author
Forward
0 new messages