let's say I have following code:
import (
handlerA "some/path/handlerA"
handlerB "some/path/handlerB"
handlerC "some/path/handlerC"
handlerD "some/path/handlerD"
....
handlerZ "some/path/handlerZ"
)
func DoSomething(a handlerA.A, b handlerB.B, c handlerC.C, d handlerD.D..., z handlerZ.Z) {
a.DoA()
b.DoB()
c.DoC()
d.DoD()
....
z.DoZ()
}
I obviously made the function DoSomething(...) mockable, as this makes my function unit testable. But because of that I get way to many arguments because of all the dependencies my function needs to get injected.
Is there a better way in Golang to handle many dependencies?
.DoA()and.DoB()? They both could be just.Do(). Now it is possible to define an interface liketype Doer interface { Do() }and the signature can change toDoSomething(...Doer).