Skip to content

x/tools/godoc: does not print comments accompanying variable literals #29775

@stapelberg

Description

@stapelberg

Take the following example code:

package exported

var IPs = []string{
"127.0.0.1", // localhost

// IPv6 localhost
"::1",
}

…and render it using godoc:

% go get -u golang.org/x/tools/cmd/godoc
% go get -u github.com/stapelberg/godoc-exported
% godoc -http=localhost:6060
% google-chrome http://localhost:6060/pkg/github.com/stapelberg/godoc-exported/

You’ll see:

2019-01-16-202035_703x617_scrot

I.e., the comments are not printed.

I’m guessing this is a consequence of go/ast’s comment handling being tricky. I tried taking a stab at it, but couldn’t get very far, so I figured I’d file a bug and see if someone more familiar with the code can advise what needs to be done here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.ToolsThis label describes issues relating to any tools in the x/tools repository.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions