1
0
mirror of https://github.com/golang/go synced 2024-11-18 11:34:45 -07:00

internal/imports: continue past parse errors

A user that's editing packages in their workspace may introduce parse
errors (missing package statement), but we still want to be able to add
imports for them. Continue past parse errors.

Fixes golang/go#39315.

Change-Id: I3bbf428e7b9ef32a87258af2dafbe0d7b86b7348
Reviewed-on: https://go-review.googlesource.com/c/tools/+/237686
Run-TryBot: Heschi Kreinick <heschi@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
This commit is contained in:
Heschi Kreinick 2020-06-12 16:16:03 -04:00 committed by Rebecca Stambler
parent a1e2396bbd
commit 54c614fe05

View File

@ -1325,7 +1325,10 @@ func loadExportsFromFiles(ctx context.Context, env *ProcessEnv, dir string, incl
fullFile := filepath.Join(dir, fi.Name())
f, err := parser.ParseFile(fset, fullFile, nil, 0)
if err != nil {
return "", nil, fmt.Errorf("parsing %s: %v", fullFile, err)
if env.Logf != nil {
env.Logf("error parsing %v: %v", fullFile, err)
}
continue
}
if f.Name.Name == "documentation" {
// Special case from go/build.ImportDir, not