I have a struct that two other objects implement. In this case, typeA and B repo's. There's some initialization code, which are represented as ellipses here. The initialization code is completely duplicated between both constructors, and isn't a big deal while I only have two dbRepo
's, but as I create more I will worry a bit more about the bad practice. Is there any way to generalize this with an interface?
type dbRepo struct {
foo string
bar string
}
type typeARepo dbRepo
type typeBRepo dbRepo
func newTypeARepo(foo, bar string) {
...
}
func newTypeBRepo(foo, bar string) {
...
}