Skip to content
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

Print got and want with %+v format flag instead of %v by default #228

Open
kakuiho opened this issue Dec 19, 2024 · 0 comments
Open

Print got and want with %+v format flag instead of %v by default #228

kakuiho opened this issue Dec 19, 2024 · 0 comments

Comments

@kakuiho
Copy link

kakuiho commented Dec 19, 2024

Requested feature A clear description of the desired feature and an example of
how it would be used.

When a matcher reports a failure, it prints the received (Got) vs the expected (Want) value.

       Got: &{123 456 789} (*foo.FooORM)
        Want: is equal to &{1234 456 789} (*foo.FooORM)

We don't know which field of foo.FooORM is mismatch.

Why the feature is needed A clear description of how this feature is not
served by existing functionality in gomock.

Better format should be

       Got: &{a:123 b:456 c:789} (*foo.FooORM)
       Want: is equal to &{a:1234 b:456 c:789} (*foo.FooORM)

It prints struct with their field names by default, user would easier to figure it out what is wrong(the field a value is mismatch).

(Optional) Proposed solution A clear description of a proposed method for
adding this feature to gomock.

Print struct with %+v format flag instead of %v in Got and Want by default.

return fmt.Sprintf("%v", x)

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

No branches or pull requests

1 participant