cmd/apidiff: check for package existence
This provides a nicer error experience when providing a package that does not
exist.
Change-Id: I816df12556832af67f432cccd91da2dc5232b798
Reviewed-on: https://go-review.googlesource.com/c/155577
Reviewed-by: Jonathan Amsterdam <jba@google.com>
diff --git a/cmd/apidiff/main.go b/cmd/apidiff/main.go
index 552062e..7cc0caf 100644
--- a/cmd/apidiff/main.go
+++ b/cmd/apidiff/main.go
@@ -92,6 +92,9 @@
if err != nil {
return nil, err
}
+ if len(pkgs) == 0 {
+ return nil, fmt.Errorf("found no packages for import %s", importPath)
+ }
if len(pkgs[0].Errors) > 0 {
return nil, pkgs[0].Errors[0]
}