8000 Print got and want with `%+v` format flag instead of `%v` by default · Issue #228 · uber-go/mock · GitHub
[go: up one dir, main page]

Skip to content

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

Open

Description

@kakuiho

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      0