mirror of https://github.com/golang/go.git
internal/lsp/cache: fix panic in GOPATH mode
We can't assume that we're in module mode when we rebuild the imports cache. (This is a long standing bug, but I suspect it was made more common by my recent CL that refactored this code.) Fixes golang/go#43544. Change-Id: Ie35c43e6b6e496bd2fbf49cf9bf06c28cf1dab80 Reviewed-on: https://go-review.googlesource.com/c/tools/+/282113 Trust: Heschi Kreinick <heschi@google.com> Run-TryBot: Heschi Kreinick <heschi@google.com> Reviewed-by: Rebecca Stambler <rstambler@golang.org> gopls-CI: kokoro <noreply+kokoro@google.com> TryBot-Result: Go Bot <gobot@golang.org>
This commit is contained in:
parent
6f6e4b659e
commit
5bd8423ece
|
|
@ -78,7 +78,9 @@ func (s *importsState) runProcessEnvFunc(ctx context.Context, snapshot *snapshot
|
|||
// unnecessary work and potentially mess up the go.mod file.
|
||||
if s.cleanupProcessEnv != nil {
|
||||
if resolver, err := s.processEnv.GetResolver(); err == nil {
|
||||
resolver.(*imports.ModuleResolver).ClearForNewMod()
|
||||
if modResolver, ok := resolver.(*imports.ModuleResolver); ok {
|
||||
modResolver.ClearForNewMod()
|
||||
}
|
||||
}
|
||||
s.cleanupProcessEnv()
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue