I have two classes Foo and Bar that each have 10-12 methods, but just a couple of the methods are slightly different. The methods that are different are "With" methods that return Foo for the *Foo class and *Bar for the Bar class.
To reduce code duplication, I have
type Foo struct {
inner
}
type Bar struct {
inner
}
inner has the methods that are the same for both Foo and Bar so we have
func (i *inner) MethodA() {
}
func (i *inner) MethodB() {
}
etc.
In a file named example_test.go, I have
func ExampleFoo_MethodA() {
}
func ExampleFoo_MethodB() {
}
etc.
When I run godoc on the code it correctly shows MethodA and MethodB as being methods of Foo that take pointer receivers. However, not all the example code that I wrote for class Foo shows up. Only the example code for the "With" methods that are written as direct methods of Foo rather than "inner" show up.
I would expect that all my example code for Foo would show up including the example code for the methods of "inner"
Is this behaviour that I am seeing by design? Or could it be a bug in godoc? Or do I need to be doing something different?
Also when I run go vet on my code, it doesn't flag anything as being wrong.