FAQ
Hi,

I'm working on a Go package and running into an odd behavior when
working with embedded types. I have been able to use non-exported,
embedded types to an arbitrary depth without issue in the code, but
when I look at the godoc generated output, only methods whose receiver
is directly embedded in an exported type are shown.

Here's a fairly minimal (albeit meaningless) example:

type a struct {}

func (a a) DoSomething() {}

type b struct {
     a
}

type Y struct {
     a
}

type Z struct {
     b
}

In this very contrived example, I expect to be able to call
DoSomething() on instances of Y or Z, and that works fine. When I look
at the generated documentation for a package with types of this
structure, however, DoSomething is documented as a method of Y but not
of Z.

While searching for information, I did find
https://code.google.com/p/go/issues/detail?id=1000, which seems to
have been looking for the full method set but looks like it was closed
with just a subset of that functionality. Is this working as intended
right now? Right now to get the documentation I'm looking for, I have
to implement a forwarding method on b for DoSomething just to make
sure that godoc shows the method everywhere appropriate.

Thanks,
Ian

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-nuts @
categoriesgo
postedSep 9, '13 at 9:45p
activeSep 9, '13 at 9:45p
posts1
users1
websitegolang.org

1 user in discussion

Ian Peters: 1 post

People

Translate

site design / logo © 2022 Grokbase