mirror of https://github.com/golang/go.git
internal/lsp/cache: check for nil WorkFile.Go
Fixes golang/vscode-go#2121 Change-Id: Icf44c8bb4079c0bcba83a9512f939260bbb5b6de Reviewed-on: https://go-review.googlesource.com/c/tools/+/393856 Trust: Robert Findley <rfindley@google.com> Run-TryBot: Robert Findley <rfindley@google.com> gopls-CI: kokoro <noreply+kokoro@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
This commit is contained in:
parent
5ea13d0d89
commit
86b02b36c4
|
|
@ -505,10 +505,13 @@ func parseGoWork(ctx context.Context, root, uri span.URI, contents []byte, fs so
|
|||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
if workFile.Go.Version != "" {
|
||||
if err := modFile.AddGoStmt(workFile.Go.Version); err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
// Require a go directive, per the spec.
|
||||
if workFile.Go == nil || workFile.Go.Version == "" {
|
||||
return nil, nil, fmt.Errorf("go.work has missing or incomplete go directive")
|
||||
}
|
||||
if err := modFile.AddGoStmt(workFile.Go.Version); err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
return modFile, modFiles, nil
|
||||
|
|
|
|||
Loading…
Reference in New Issue