Open
Description
Proposal Details
Hi!
I was recently using a new GO module in my project.
There was code like this:
type (
A struct {}
B struct { *A }
)
func (*A) Foo() {}
Tybe B however was a large struct with many methods and exported fields.
I had a code example that used method Foo
and I just wanted to know more about i.
I used go doc B.Foo
but it said doc: no method or field B.Foo in package
.
I suppose, that because call like this is 100% possible &B{}.Foo()
, above go doc
call should return documentation for Foo
Metadata
Metadata
Assignees
Labels
Type
Projects
Milestone
Relationships
Development
No branches or pull requests
Activity
gabyhelp commentedon Sep 23, 2024
Related Issues and Documentation
(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.)
gucio321 commentedon Sep 23, 2024
#1000 seems similar but it was in 2010 and there was a regression since that (?)
zigo101 commentedon Sep 23, 2024
As #1000 was ever fixed, so this should not be a proposal?
gucio321 commentedon Sep 23, 2024
@zigo101 so a bug? Could you change pls? Or should i open another issue as a bug?
ianlancetaylor commentedon Sep 23, 2024
I haven't verified this, but as reported it's just a bug. This issue is fine as is. Thanks.
[-]proposal: cmd/go: doc: doesn't show embeded struct's methods[/-][+]cmd/go: doc: doesn't show embedded struct's methods[/+]codekitchen commentedon Sep 25, 2024
I investigated this a bit and found that this change in behavior, hiding methods from exported embeds, was intentional in response to #2791 . So I don't think this qualifies as a bug?
Background info from my investigation:
The current src/go/doc package intentionally hides methods from exported embeds by default. It does include unexported embedded methods, for instance:
go doc B.Foo
will show the method in this case, becausea
is not exported.To revert back to showing exported embedded methods too, the
go doc
command at src/cmd/doc could pass theAllMethods
mode flag to src/go/doczigo101 commentedon Sep 26, 2024
The design difference here looks unnecessary.