mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/go/internal/load: use setLoadPackageDataError in loadImport
This makes the error handling in loadImport somewhat more uniform, with no discernable effect on reported errors. Noticed in CL 303869. Updates #36087 Updates #38034 This somewhat simplifies the code, with no discernable effect on Change-Id: I30521f658f264d6f99d1844d6701269bbb372246 Reviewed-on: https://go-review.googlesource.com/c/go/+/304069 Trust: Bryan C. Mills <bcmills@google.com> Run-TryBot: Bryan C. Mills <bcmills@google.com> Reviewed-by: Michael Matloob <matloob@golang.org> Reviewed-by: Jay Conrod <jayconrod@google.com>
This commit is contained in:
parent
adb037d67a
commit
4889afe8f8
1 changed files with 15 additions and 12 deletions
|
|
@ -672,22 +672,25 @@ func loadImport(ctx context.Context, pre *preload, path, srcDir string, parent *
|
||||||
pre.preloadImports(ctx, bp.Imports, bp)
|
pre.preloadImports(ctx, bp.Imports, bp)
|
||||||
}
|
}
|
||||||
if bp == nil {
|
if bp == nil {
|
||||||
|
p := &Package{
|
||||||
|
PackagePublic: PackagePublic{
|
||||||
|
ImportPath: path,
|
||||||
|
Incomplete: true,
|
||||||
|
},
|
||||||
|
}
|
||||||
if importErr, ok := err.(ImportPathError); !ok || importErr.ImportPath() != path {
|
if importErr, ok := err.(ImportPathError); !ok || importErr.ImportPath() != path {
|
||||||
// Only add path to the error's import stack if it's not already present on the error.
|
// Only add path to the error's import stack if it's not already present
|
||||||
|
// in the error.
|
||||||
|
//
|
||||||
|
// TODO(bcmills): setLoadPackageDataError itself has a similar Push / Pop
|
||||||
|
// sequence that empirically doesn't trigger for these errors, guarded by
|
||||||
|
// a somewhat complex condition. Figure out how to generalize that
|
||||||
|
// condition and eliminate the explicit calls here.
|
||||||
stk.Push(path)
|
stk.Push(path)
|
||||||
defer stk.Pop()
|
defer stk.Pop()
|
||||||
}
|
}
|
||||||
// TODO(bcmills): Why are we constructing Error inline here instead of
|
p.setLoadPackageDataError(err, path, stk, nil)
|
||||||
// calling setLoadPackageDataError?
|
return p
|
||||||
return &Package{
|
|
||||||
PackagePublic: PackagePublic{
|
|
||||||
ImportPath: path,
|
|
||||||
Error: &PackageError{
|
|
||||||
ImportStack: stk.Copy(),
|
|
||||||
Err: err,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
importPath := bp.ImportPath
|
importPath := bp.ImportPath
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue