Remix.run Logo
the_gipsy 2 years ago

> The implementing package should return concrete (usually pointer or struct) types

It's in the first paragraph. It goes on in the second:

> Do not define interfaces on the implementor side of an API “for mocking”; instead, design the API so that it can be tested using the public API of the real implementation.

And yes, io.Reader/Writer violate that too, because either the tenet is wrong or the design of interfaces in go is wrong.

> Even more obviously your link isn't talking about functions but packages.

It doesn't matter: your exporting errors behind the error interface, not your concrete error implementation. If you're just using one of the many ways to create stringly errors (!) like fmt.Errorf, you maybe don't notice but you are in fact returning interfaces all the time.