Skip to content

Commit 477f926

Browse files
findleyrgopherbot
authored andcommitted
gopls/internal/cache: fix module resolver cache refreshing
An apparent bad merge in CL 561235 caused the critical component-- clearing the resolver for a new scan--to be dropped. Fix this, so that the imports state is actually refreshed asynchronously. It is surprising that this was not reported, though I see perhaps two related comments in survey results. Most likely adding a new import is infrequent enough that users were simply confused, or learned to restart gopls (alas). Also, add more instrumentation that would help debug golang/go#67289. For golang/go#67289 Change-Id: I50d70a470eb393caf9e0b41856997942372b216f Reviewed-on: https://go-review.googlesource.com/c/tools/+/590377 Auto-Submit: Robert Findley <[email protected]> Reviewed-by: Alan Donovan <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]>
1 parent c222f40 commit 477f926

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

internal/gocommand/invoke.go

+12-5
Original file line numberDiff line numberDiff line change
@@ -200,12 +200,14 @@ func (i *Invocation) runWithFriendlyError(ctx context.Context, stdout, stderr io
200200
return
201201
}
202202

203-
func (i *Invocation) run(ctx context.Context, stdout, stderr io.Writer) error {
204-
log := i.Logf
205-
if log == nil {
206-
log = func(string, ...interface{}) {}
203+
// logf logs if i.Logf is non-nil.
204+
func (i *Invocation) logf(format string, args ...any) {
205+
if i.Logf != nil {
206+
i.Logf(format, args...)
207207
}
208+
}
208209

210+
func (i *Invocation) run(ctx context.Context, stdout, stderr io.Writer) error {
209211
goArgs := []string{i.Verb}
210212

211213
appendModFile := func() {
@@ -277,7 +279,12 @@ func (i *Invocation) run(ctx context.Context, stdout, stderr io.Writer) error {
277279
cmd.Dir = i.WorkingDir
278280
}
279281

280-
defer func(start time.Time) { log("%s for %v", time.Since(start), cmdDebugStr(cmd)) }(time.Now())
282+
debugStr := cmdDebugStr(cmd)
283+
i.logf("starting %v", debugStr)
284+
start := time.Now()
285+
defer func() {
286+
i.logf("%s for %v", time.Since(start), debugStr)
287+
}()
281288

282289
return runCmdContext(ctx, cmd)
283290
}

0 commit comments

Comments
 (0)