3 ms·
You don’t. Each consumer of something declares what it needs via an interface, something concrete may be passed that implements it - including fakes for tests.
by jen20 2y ago
You don’t. Each consumer of something declares what it needs via an interface, something concrete may be passed that implements it - including fakes for tests.
Of course this doesn’t apply when using interfaces for polymorphic return types in a library, but that is a distinct use case for interfaces to address.
Perhaps some of this is just taste, but this is the way I’ve found interfaces in Go to be most useful.