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

Comments

@dsnet
Copy link
Member

@dsnet 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

This comment has been minimized.

Copy link
Contributor

@agnivade agnivade commented Mar 27, 2019

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

@gopherbot

This comment has been minimized.

Copy link

@gopherbot gopherbot commented May 22, 2019

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.)

@gopherbot gopherbot closed this May 22, 2019
@cespare cespare removed the WaitingForInfo label May 22, 2019
@cespare

This comment has been minimized.

Copy link
Contributor

@cespare cespare commented May 22, 2019

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

@agnivade

This comment has been minimized.

Copy link
Contributor

@agnivade agnivade commented Nov 11, 2019

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

This comment has been minimized.

Copy link

@gopherbot gopherbot commented Nov 11, 2019

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

@gopherbot gopherbot closed this in 72e043e Nov 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants
You can’t perform that action at this time.