Skip to content

feat: add option to ignore unexported interface methods instead of error returning#104

Open
necrosisoff wants to merge 2 commits into
hexdigest:masterfrom
necrosisoff:ignore_unexported
Open

feat: add option to ignore unexported interface methods instead of error returning#104
necrosisoff wants to merge 2 commits into
hexdigest:masterfrom
necrosisoff:ignore_unexported

Conversation

@necrosisoff

Copy link
Copy Markdown
  • added -u option to gen command
  • don't return an error if option set
  • remove unexperted method from list if option set

@jaggman

jaggman commented Nov 29, 2025

Copy link
Copy Markdown

@hexdigest will you add this?
It'll useful for generate gRPC wrappers

Виктор Донос added 2 commits May 25, 2026 12:48
@hexdigest

Copy link
Copy Markdown
Owner

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 -u is a good idea.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants