davecgh / go-spew

Implements a deep pretty printer for Go data structures to aid in debugging
ISC License
5.98k stars 361 forks source link

Implementing OmitEmpty flag to skip zero-value fields. #77

Closed peterebden closed 1 year ago

peterebden commented 6 years ago

Found that I had a need for this too, so thought I'd have a crack at it.

Resolves #22

peterebden commented 6 years ago

Hmmmm, the Travis failure is not related to this PR, go vet is complaining about unsafe.Pointer in a couple of other places. Let me know if there's anything I should do for it...

mediocregopher commented 5 years ago

Any update on this? I'd really love this feature :3

Edit: @peterebden I think commit db69d09 fixed the travis issue, you might just need to rebase.

peterebden commented 5 years ago

To be honest I'd forgotten about this PR.

I can see the motivation for your proposed changes, but I'm not sure if printing empty slices would have a negative impact on what I wanted it for originally. I guess I'm kind of agnostic on it, but this is very stale now; is this project still interested in new contributions? If not there's no point discussing further really...

maxatome commented 5 years ago

@davecgh @dajohi do you accept new contributions?

awkaiser commented 4 years ago

I agree with @maxatome's suggested changes 👍

khpeek commented 1 year ago

@peterebden This change would still be most welcome in my view! Some structs I would like to debug have a plethora of fields which are unset and irrelevant to what I'm debugging; essentially I would like to print them out as if they were in JSON format with the json:",omitempty" struct tag applied everywhere, which as I understand it this contribution achieves.

peterebden commented 1 year ago

I had forgotten that this was still a thing to be honest.

I don't have any particular need for this any more (it was relevant to me in 2018, not really any more). Happy if someone else wants to copy this & continue with it, although as I mentioned above it seems this project isn't looking for contributions any more. Good luck :)