I define two struct types Type1 and Type2
type Type1 struct {
A1,B1,C1 string
}
type Type2 struct {
A1,B1 string
}
to embed them in struct type Supertype
type Supertype struct {
Type1
Type2
}
then define interface Sender with method Send in order to use for both Type1 and Type2
type Sender interface {
Send()
}
Finally I define func where I want to refer Type1 and Type2 fields
func (p Supertype) Send() {
..
p.A1 = "foo"
..
}
of course getting 'ambiguous selector p.A1' error. How to use method Send for both struct types Type1 and Type2 ? There is similar question How can two different types implement the same method in golang using interfaces? but I don't think it applies in my case