1
0
mirror of https://github.com/golang/go synced 2024-09-24 11:20:20 -06:00

cmd/doc: display a proper error when no packages are found

Fixes #32044

Change-Id: Ia220dbbe4d6851befe28dd2d4b8a1a7bc2757460
Reviewed-on: https://go-review.googlesource.com/c/go/+/178878
Run-TryBot: Agniva De Sarker <agniva.quicksilver@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
This commit is contained in:
Agniva De Sarker 2019-05-25 20:02:28 +02:00 committed by Rob Pike
parent a3863fc18a
commit d97bd5d07a

View File

@ -129,7 +129,10 @@ func parsePackage(writer io.Writer, pkg *build.Package, userPath string) *Packag
log.Fatal(err)
}
// Make sure they are all in one package.
if len(pkgs) != 1 {
if len(pkgs) == 0 {
log.Fatalf("no source-code package in directory %s", pkg.Dir)
}
if len(pkgs) > 1 {
log.Fatalf("multiple packages in directory %s", pkg.Dir)
}
astPkg := pkgs[pkg.Name]