3 ms·
> such as Go's logging not using an interface, which can bite you, leaving you with little choice but to reimplement logging for your project/company Ah yes, a
by jacques_chester 11y ago
> such as Go's logging not using an interface, which can bite you, leaving you with little choice but to reimplement logging for your project/company
Ah yes, another pet peeve. The Go standard library sometimes uses package functions, sometimes a struct with functions and then -- sometimes, not always -- has an interface that goes with that struct.
Whenever you have a library with the interface, you can fake it out for testing. When it hands back a physical struct, you wind up wrapping it.
Any time you wander into a repo drop from a company, you'll find standard lib wrappers, all written from scratch, because of this.
Golang interfaces are a strong feature of the language and they make it possible to practice more isolated unit testing. The inconsistency across the standard lib is very frustrating. Frankly I'd rather be stuck with no interfaces than the mishmash I faced.
I wanted to like Go. I really, really did.