Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/doc: -all flag misses exported variables of unexported types #31067

Closed
dsnet opened this issue Mar 27, 2019 · 5 comments
Closed

cmd/doc: -all flag misses exported variables of unexported types #31067

dsnet opened this issue Mar 27, 2019 · 5 comments
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.

Comments

@dsnet
Copy link
Member

dsnet commented Mar 27, 2019

Using go1.12

Consider the following snippet:

package foo
var X x
type x struct{}

Invoking go doc -all prints:

package foo // import "."

Notice how X is missing? It should be shown. The problem is that the logic probably files the value under the x type, but since x is not shown, it gets swallowed.

@dsnet dsnet changed the title cmd/doc: -all flag misses variables of unexported types cmd/doc: -all flag misses exported variables of unexported types Mar 27, 2019
@agnivade
Copy link
Contributor

Does X show up in godoc under ?m=all ?

@julieqiu julieqiu added the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Apr 22, 2019
@gopherbot
Copy link

Timed out in state WaitingForInfo. Closing.

(I am just a bot, though. Please speak up if this is a mistake or you have the requested information.)

@cespare cespare removed the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label May 22, 2019
@cespare
Copy link
Contributor

cespare commented May 22, 2019

I think this is a reasonable issue regardless of the answer to @agnivade's question.

@cespare cespare reopened this May 22, 2019
@agnivade agnivade added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label May 22, 2019
@agnivade
Copy link
Contributor

Looked into it. The difference lies in the code paths between (*Package).packageDoc and (*Package).allDoc. You will notice that it correctly gives the output if you give go doc, but fails to show the variable on go doc -all.

On an unrelated note, I noticed that 1.13 has a regression where the -all flag does not even print the package clause.

$cat kk.go 
package foo
var X x
type x struct{}

19:57:30-agniva-~/play/go/src/playtest$go doc -all

19:57:32-agniva-~/play/go/src/playtest$

But simply go doc does show the var X x.

$go doc 


package foo // import "playtest"

var X x

Offtopic: f736de0 introduced the regression. (@robpike). This happens because now the package clause gets printed on the first write to pkg.buf. That means nothing gets printed, if no writes happen. Not a big deal, but I guess it is technically a bug because if a file contains just the package clause, nothing gets printed. Whereas it should. I have a fix for this. Will send it shortly.

@gopherbot
Copy link

Change https://golang.org/cl/206129 mentions this issue: cmd/doc: show variables of unexported types for -all

@golang golang locked and limited conversation to collaborators Nov 11, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

5 participants