Commit d97bd5d0 authored by Agniva De Sarker's avatar Agniva De Sarker Committed by Rob Pike

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: default avatarRob Pike <r@golang.org>
parent a3863fc1
......@@ -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]
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment