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

Use GoString instead of String #331

Open
mxey opened this issue May 23, 2023 · 0 comments
Open

Use GoString instead of String #331

mxey opened this issue May 23, 2023 · 0 comments
Labels
reporter Improvements in the difference reporter

Comments

@mxey
Copy link

mxey commented May 23, 2023

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.

@dsnet dsnet added the reporter Improvements in the difference reporter label Jan 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
reporter Improvements in the difference reporter
Projects
None yet
Development

No branches or pull requests

2 participants