A clear error message, maybe like when there are no Go files: doc: no such package /tmp/z.
What did you see instead?
A confusing error message: doc: multiple packages in directory /tmp/z.
When I originally ran into this, in my non-trivial example, I was confused. Multiple packages? Did I misname my test package? Did I accidentally have two different source packages due to a typo in the package directive?
I would suggest something like doc: no non-test packages in directory /tmp/z so that it's clear that doc would have worked if I had any non-test files in the directory.
The text was updated successfully, but these errors were encountered:
FiloSottile
changed the title
go/doc: confusing error message when directory only contains test package
cmd/go: confusing error message when directory only contains test package
May 15, 2019
FiloSottile
changed the title
cmd/go: confusing error message when directory only contains test package
cmd/doc: confusing error message when directory only contains test package
May 15, 2019
Ha ! The code meant to ensure that there is only 1 package it processes. But the check is incorrect :)
if len(pkgs) != 1 {
log.Fatalf("multiple packages in directory %s", pkg.Dir)
}
Will send a CL.
agnivade
added
NeedsFix
The path to resolution is known, but the work has not been done.
and removed
GoCommand
cmd/go
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
labels
May 25, 2019
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes, but I haven't tested with go 1.11 to see if this was a 1.12 regression.
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
I created a module that only had an example test file:
And then I ran
go doc .
What did you expect to see?
A clear error message, maybe like when there are no Go files:
doc: no such package /tmp/z
.What did you see instead?
A confusing error message:
doc: multiple packages in directory /tmp/z
.When I originally ran into this, in my non-trivial example, I was confused. Multiple packages? Did I misname my test package? Did I accidentally have two different source packages due to a typo in the
package
directive?I would suggest something like
doc: no non-test packages in directory /tmp/z
so that it's clear that doc would have worked if I had any non-test files in the directory.The text was updated successfully, but these errors were encountered: