From c20eb96e6b990b455c73204a15489656106b1342 Mon Sep 17 00:00:00 2001 From: "Bryan C. Mills" Date: Wed, 11 Sep 2019 09:51:17 -0400 Subject: [PATCH] cmd/go/internal/modload: add an Unwrap method on ImportMissingError Jay suggested this in CL 189780, and it seems semantically correct. As far as I can tell this has no impact one way or the other right now, but might prevent confusion (or at least give us more experience with error handling!) in future changes. Updates #30748 Updates #28459 Updates #30322 Change-Id: I5d7e9a08ea141628ed6a8fd03c62d0d3c2edf2bb Reviewed-on: https://go-review.googlesource.com/c/go/+/194817 Run-TryBot: Bryan C. Mills TryBot-Result: Gobot Gobot Reviewed-by: Jay Conrod --- src/cmd/go/internal/modload/import.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/cmd/go/internal/modload/import.go b/src/cmd/go/internal/modload/import.go index bb5e05e9e3..f0777089d4 100644 --- a/src/cmd/go/internal/modload/import.go +++ b/src/cmd/go/internal/modload/import.go @@ -48,6 +48,10 @@ func (e *ImportMissingError) Error() string { return fmt.Sprintf("missing module for import: %s@%s provides %s", e.Module.Path, e.Module.Version, e.ImportPath) } +func (e *ImportMissingError) Unwrap() error { + return e.QueryErr +} + // Import finds the module and directory in the build list // containing the package with the given import path. // The answer must be unique: Import returns an error