Skip to content

Format matched arguments with %v to avoid panic#596

Merged
ernesto-jimenez merged 2 commits intostretchr:masterfrom
gz-c:print-no-panic
Jun 9, 2018
Merged

Format matched arguments with %v to avoid panic#596
ernesto-jimenez merged 2 commits intostretchr:masterfrom
gz-c:print-no-panic

Conversation

@gz-c
Copy link
Contributor

@gz-c gz-c commented May 6, 2018

Some values will panic when fmt.Sprintf'd with %s, e.g. https://godoc.org/github.com/boltdb/bolt#Tx.

When mocking a method that has such a value in its arguments, the program will panic due to Argument.Diff attempting to print the interface{} type with %s.

Normally the compiler will prevent using such a value in a formatter but the code bypasses this by operating on interface{}.

This PR changes the formatter to use (%T=%v). %T is used to mimic the previous behaviour which generated outputs like %!s(int=123).

@gz-c gz-c changed the title Print no panic Format matched arguments with %v to avoid panic May 6, 2018
@ernesto-jimenez
Copy link
Member

@gz-c thanks!

@ernesto-jimenez ernesto-jimenez merged commit f35b8ab into stretchr:master Jun 9, 2018
@gz-c gz-c deleted the print-no-panic branch June 9, 2018 16:55
@gz-c gz-c mentioned this pull request Sep 4, 2020
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.

2 participants