-
Notifications
You must be signed in to change notification settings - Fork 17.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cmd/go: eliminate redundancy in import error messages
This change introduces a new interface, load.ImportPathError. An error may satisfy this by providing an ImportPath method and including the import path in its error text. modload.ImportMissingError satisfies this interface. load.ImportErrorf also provides a convenient way to create an error satisfying this interface with an arbitrary message. When load.PackageError formats its error text, it may omit the last path on the import stack if the wrapped error satisfies ImportPathError and has a matching path. To make this work, PackageError.Err is now an error instead of a string. PackageError.MarshalJSON will write Err as a string for 'go list -json' output. When go/build.Import invokes 'go list' in module mode, it now runs with '-e' and includes '.Error' in the output format instead of expecting the error to be in the raw stderr text. If a package error is printed and a directory was not found, the error will be returned without extra decoration. Fixes #34752 Change-Id: I2d81dab7dec19e0ae9f51f6412bc9f30433a8596 Reviewed-on: https://go-review.googlesource.com/c/go/+/199840 Run-TryBot: Jay Conrod <jayconrod@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Bryan C. Mills <bcmills@google.com>
- Loading branch information
Jay Conrod
committed
Oct 9, 2019
1 parent
b3104fe
commit 32b6eb8
Showing
9 changed files
with
167 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.