Skip to content

Throw error when no interfaces are provided #144

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

keddad
Copy link

@keddad keddad commented Jul 1, 2025

Hello! I've tried minimock recently, and it's a great tool. However, when I tried it, I got stuck for a while because I accidentally specified a struct implementing an interface instead of the interface itself.

Consider the following source code:

package main

type Formatter interface {
	Format(string, ...interface{}) string
}

type FormatterImpl struct {
}

func (i *FormatterImpl) Format(string, ...interface{}) string {
	return ""
}

If instead of minimock -i Formatter you run minimock -i FormatterImpl, no output is generated, which is expected. However, there is no error - it just exits silently. Since specifying a struct instead of interface is always wrong, I propose throwing an error in this case - it's a small patch, but it might save some of the user's time.

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.

1 participant