edgevpn
edgevpn copied to clipboard
Return an interface instead of a struct
I'm quite against returning interfaces - I do believe structs are much better so the consumer actually can tie together without being bound to a specific interface that needs to be satisfied. Ideally the consumer should just take care of that bit. Why is this needed?
I'm quite against returning interfaces - I do believe structs are much better so the consumer actually can tie together without being bound to a specific interface that needs to be satisfied. Ideally the consumer should just take care of that bit. Why is this needed?
mainly because you are bounded tto send the exact struct that this function needs. With an interface you can pass any object that implements that interface so in this case the caller can have its own logger implementation and pass that instead of forcing the caller to pass as struct. Thats the whole point of the interface thingie in golang no?