feat: add option to ignore unexported interface methods instead of error returning#104
feat: add option to ignore unexported interface methods instead of error returning#104necrosisoff wants to merge 2 commits into
Conversation
|
@hexdigest will you add this? |
(cherry picked from commit 1ee915d)
97d9772 to
4bb57fd
Compare
|
I don’t think ignoring unexported methods is the right solution. If an interface embeds an unexported method, that is usually intentional: the package author is preventing external implementations (including mocks). Skipping that method produces a type that does not actually implement the source interface, which can be misleading. For gRPC or other generated APIs, the better pattern is usually to define a local consumer-side interface with only the methods the package actually needs, then generate mocks/wrappers against that local interface instead of the full generated interface. This also avoids coupling tests to the entire generated API surface. If your code depends on the server/client interface defined in some other package (e.g. generated gRPC code) you're doing something wrong and it's a bad Go code. I don't think that promoting this anti-pattern via |
-uoption togencommand