We have a code sample which is along the following lines
type Foo interface {
DoSome() error
}
type AbstractFoo struct {
Foo
X
Y
}
type ConcreteFoo struct {
.....
}
This looks all good
but the creation of ConcreteFoo
looks something like this
concreteFoo := &AbstractFoo{
X: x,
Y: y,
}
concreteFoo.Foo = concreteFoo
So essentially a concrete implementation just means initialising an Abstract struct and setting the member interface as self.
This sounds wrong to me as it reads like construct a struct and tell it that its implementation field is self.
I understand this is happening as developers coming from java and other OOP paradigm are trying to implement it. It does not read like an idiomatic golang code but I am also not able to point out the problem.
What would be the idiomatic version of this code ?