diff --git a/gomock/call.go b/gomock/call.go index e1fe222a..9f0d98c1 100644 --- a/gomock/call.go +++ b/gomock/call.go @@ -498,7 +498,7 @@ func (c *Call) addAction(action func([]any) []any) { } func formatGottenArg(m Matcher, arg any) string { - got := fmt.Sprintf("%v (%T)", arg, arg) + got := fmt.Sprintf("%+v (%T)", arg, arg) if gs, ok := m.(GotFormatter); ok { got = gs.Got(arg) } diff --git a/gomock/controller_test.go b/gomock/controller_test.go index 7e0397d7..74c415c0 100644 --- a/gomock/controller_test.go +++ b/gomock/controller_test.go @@ -298,13 +298,13 @@ func TestUnexpectedArgValue_FirstArg(t *testing.T) { // the method argument (of TestStruct type) has 1 unexpected value (for the Message field) ctrl.Call(subject, "ActOnTestStructMethod", TestStruct{Number: 123, Message: "no message"}, 15) }, "Unexpected call to", "doesn't match the argument at index 0", - "Got: {123 no message} (gomock_test.TestStruct)\nWant: is equal to {123 hello %s} (gomock_test.TestStruct)") + "Got: {Number:123 Message:no message} (gomock_test.TestStruct)\nWant: is equal to {Number:123 Message:hello %s} (gomock_test.TestStruct)") reporter.assertFatal(func() { // the method argument (of TestStruct type) has 2 unexpected values (for both fields) ctrl.Call(subject, "ActOnTestStructMethod", TestStruct{Number: 11, Message: "no message"}, 15) }, "Unexpected call to", "doesn't match the argument at index 0", - "Got: {11 no message} (gomock_test.TestStruct)\nWant: is equal to {123 hello %s} (gomock_test.TestStruct)") + "Got: {Number:11 Message:no message} (gomock_test.TestStruct)\nWant: is equal to {Number:123 Message:hello %s} (gomock_test.TestStruct)") reporter.assertFatal(func() { // The expected call wasn't made. diff --git a/gomock/string.go b/gomock/string.go index ec4ca7e4..3bf16b12 100644 --- a/gomock/string.go +++ b/gomock/string.go @@ -15,7 +15,7 @@ func getString(x any) string { if s, ok := x.(fmt.Stringer); ok { return s.String() } - return fmt.Sprintf("%v", x) + return fmt.Sprintf("%+v", x) } // isGeneratedMock checks if the given type has a "isgomock" field,