google/go-cmp

Use GoString instead of String

mxey opened this issue · 0 comments

mxey commented

cmp's diff output is mostly valid Go and so can be nicely used to fill in the want part of a test by running the test with an empty want and then copying from cmp's diff output.

However when cmp is printing, for example, two different time.Time values, it uses the formatting as returned by the String() method. I think it would be more useful, or should be an option, it if used the GoString() method instead. GoString() is supposed to return valid Go code, which would fit into the existing output style of cmp. For time.Time, it returns Go code to create that time value, which is more useful than the string format of the value.