Skip to content

Commit 22a56b6

Browse files
author
Bryan C. Mills
committed
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 golang#36460 Change-Id: I963e39cc7fbc457c12a626c1402c0be29203d23b Reviewed-on: https://go-review.googlesource.com/c/go/+/314633 Trust: Bryan C. Mills <[email protected]> Run-TryBot: Bryan C. Mills <[email protected]> TryBot-Result: Go Bot <[email protected]> Reviewed-by: Michael Matloob <[email protected]>
1 parent f893f35 commit 22a56b6

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

src/cmd/go/internal/modload/import.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,11 @@ func importFromModules(ctx context.Context, path string, rs *Requirements) (m mo
303303
} else {
304304
mg, err = rs.Graph(ctx)
305305
if err != nil {
306-
return module.Version{}, "", &ImportMissingError{Path: path, QueryErr: err}
306+
// We might be missing one or more transitive (implicit) dependencies from
307+
// the module graph, so we can't return an ImportMissingError here — one
308+
// of the missing modules might actually contain the package in question,
309+
// in which case we shouldn't go looking for it in some new dependency.
310+
return module.Version{}, "", err
307311
}
308312
}
309313

0 commit comments

Comments
 (0)