[tools] gopls/internal/filecache: add GetOrFatal and ErrNoCache

0 views
Skip to first unread message

Alan Donovan (Gerrit)

unread,
Jun 5, 2026, 10:37:54 AM (2 days ago) Jun 5
to goph...@pubsubhelper.golang.org, golang-...@googlegroups.com, golang...@luci-project-accounts.iam.gserviceaccount.com, Alex Putman, golang-co...@googlegroups.com

Alan Donovan 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/filecache/filecache.go
Insertions: 1, Deletions: 1.

@@ -90,7 +90,7 @@
//
// Get returns [ErrNoCache] if the cache did not exist and could not
// be created. This may be due to ENOSPC, deletion of the process's
-// executable, or deletion or corruption of the cache by external
+// executable, deletion or corruption of the cache by external
// meddling while gopls is running, or by faulty hardware (see issue
// #67433). In this case, terminating the application is likely the
// best course; see [GetOrFatal].
```

Change information

Commit message:
gopls/internal/filecache: add GetOrFatal and ErrNoCache

Filecache errors are of three kinds:
1. ErrNotFound, the normal cache miss case.
2. failure to create the cache for some reason,
such as ENOSPC. This is generally unrecoverable,
and best not treated as a cache miss since performance
will inevitably be terrible.
3. unexpected error reading a cache entry.

This change defines a distinguished error type, ErrNoCache,
for errors of the second kind, and adds a helper, GetOrFatal,
that calls log.Fatal when this error is encountered; it also
logs other unexpected errors. This makes all call sites much
simpler, and should address the various telemetry reports.

Fixes golang/go#79803
Fixes golang/go#67433
Change-Id: I6fd2a425d0600603e356594e9a576607c33d40f5
Reviewed-by: Alex Putman <apu...@golang.org>
Files:
  • M gopls/internal/cache/analysis.go
  • M gopls/internal/cache/check.go
  • M gopls/internal/cache/snapshot.go
  • M gopls/internal/cache/symbols.go
  • M gopls/internal/filecache/filecache.go
Change size: M
Delta: 5 files changed, 55 insertions(+), 51 deletions(-)
Branch: refs/heads/master
Submit Requirements:
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: I6fd2a425d0600603e356594e9a576607c33d40f5
Gerrit-Change-Number: 787160
Gerrit-PatchSet: 4
Gerrit-Owner: Alan Donovan <adon...@google.com>
Gerrit-Reviewer: Alan Donovan <adon...@google.com>
Gerrit-Reviewer: Alex Putman <apu...@golang.org>
open
diffy
satisfied_requirement
Reply all
Reply to author
Forward
0 new messages