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

Add support for fmt.GoStringer interface #26

Open
2opremio opened this issue Aug 27, 2020 · 1 comment
Open

Add support for fmt.GoStringer interface #26

2opremio opened this issue Aug 27, 2020 · 1 comment
Labels
breaking_change Breaking change; potential feature for a v2 branch

Comments

@2opremio
Copy link

2opremio commented Aug 27, 2020

Apart from fmt.Stringer, it would be good if fmt.GoStringer was supported

I think GoStringer should (at least by default) have higher priority than fmt.Stringer

@kylelemons
Copy link
Owner

Thanks for the request. It's certainly probable that it should have been, but I am very reluctant to add something like this that will change the behavior for existing code, as (for better or worse) some users of this library have hard-coded the expected output of Print instead of comparing against a golden value with Diff. Adding a config flag is certainly an option, but I am also reluctant to add configuration for things that can be accommodated with existing configs.

For anyone who comes across this, my recommended current approach is to use config.Formatter to opt-in to GoString for the types you require.

I will tag this as a potential feature for v2, in case we do wind up with enough breaking changes to require one.

Also, check out package cmp. I generally think it does the job better and is already more featureful than pretty.

@kylelemons kylelemons added the breaking_change Breaking change; potential feature for a v2 branch label Aug 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking_change Breaking change; potential feature for a v2 branch
Projects
None yet
Development

No branches or pull requests

2 participants