1
0
mirror of https://github.com/golang/go synced 2024-11-11 22:50:22 -07:00

cmd/go/internal/modload: in importFromModules, do not wrap module graph errors in ImportMissingError

If an error occurs in loading the module graph (such as a missing
checksum for a relevant go.mod file), that error should be terminal
and we should not look elsewhere to try to resolve the import. An
ImportMissingError instructs the caller to do exactly that, so don't
use that error type for this case.

(This behavior is tested incidentally in a later CL in this stack.)

For #36460

Change-Id: I963e39cc7fbc457c12a626c1402c0be29203d23b
Reviewed-on: https://go-review.googlesource.com/c/go/+/314633
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
This commit is contained in:
Bryan C. Mills 2021-04-28 11:47:49 -04:00
parent f893f35d9f
commit 22a56b629d

View File

@ -303,7 +303,11 @@ func importFromModules(ctx context.Context, path string, rs *Requirements) (m mo
} else {
mg, err = rs.Graph(ctx)
if err != nil {
return module.Version{}, "", &ImportMissingError{Path: path, QueryErr: err}
// We might be missing one or more transitive (implicit) dependencies from
// the module graph, so we can't return an ImportMissingError here — one
// of the missing modules might actually contain the package in question,
// in which case we shouldn't go looking for it in some new dependency.
return module.Version{}, "", err
}
}