2 ms·
Your code should accept interfaces, not the S3 struct. Interfaces are light-weight, and it's okay to define an interface that is just the subset of functionali
by fwip 9y ago
Your code should accept interfaces, not the S3 struct.
Interfaces are light-weight, and it's okay to define an interface that is just the subset of functionality your code needs.
- burntsushi 9y agoBut this advice is kind of ridiculous in its unqualified form as you have presented it. If folks followed your advice, there wouldn't be an "io" package in the standard library. So why does it exist? Because it's damn useful to not define interfaces every single time you need them. It gets old real fast. This is exactly what the GP is saying.