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 GoStringer support #68
Conversation
Print values using the `GoString()` method (from `fmt.GoStringer()`) if implemented.
Hi @2opremio, thanks for doing this work! I'm a little uncertain about the purpose of this change. What problem are you running into that this would help with? I ask because this package is meant to show the structure of the data. Calling the method GoString (or String) seems like it would often defeat the purpose. |
I need to print large structures with long binary arrays which can be highly simplified and shortened by using I was using
|
If you read In fact, the example prints the creation of a struct reference, instead of a pointer which is exactly what this library does automatically. This arguably hides information which could be valuable for debugging (the pointer is not printed anymore) but that drawback is minimal compared to showing the full structure by traversing the data structurel (you can always use ``%v` if you really want to see the pointers). |
Another use case is showing constant symbol names instead of literals. For instance:
You can easily define a |
Those are good points! If the GoString method returns something that's not useful, then too bad I guess. Assuming it's doing its job, then it's a good fit for our purpose here. But I think it should not be an option unless we're sure people really need both behaviors. Ideally we would figure out the best thing to do and just make it do that. And it seems like the best thing is to call GoString. What do you think? |
I agree, I am think we should just call |
Oh yes, my apologies, I was confusing this PR with the flag in #69. |
Thanks again! This looks like it'll help make the output more readable. 🙌 |
no worries! Could you take a look at #69 ? |
Print values using the
GoString()
method (fromfmt.GoStringer()
) if implemented.This gets the formatter closer the behavior of the
fmt
stdlib.