re: Interfaces in Go VIEW POST

FULL DISCUSSION
 

I could see why u'de like to declare dependencies like http
But why would you hassel yourself for a logger?
I'de rather to setup logger config for tests at the beginning of the test suite (i usually turn it off) thus declaring only the important dependecies such as http calls ...

 

Sometimes loggers are fine global, but sometimes, particularly if you don't want to be tied to one logging implementation, it's better to make the dependency explicit because your code can evolve much more easily as software trends start to mature.

I hear you though, I use a global logger when it makes sense and use dependency injection when it makes sense. Refactoring like this is all about situational awareness. There is no one size fits all solution.

code of conduct - report abuse