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

Omit empty as an option #22

Open
johngb opened this issue Dec 29, 2014 · 4 comments
Open

Omit empty as an option #22

johngb opened this issue Dec 29, 2014 · 4 comments

Comments

@johngb
Copy link

johngb commented Dec 29, 2014

Often I'm working with large structs which have fields which are usually empty, but which are of a lot of interest if not empty. I would love there to be an option to omit empty fields. The problem of course is how we define empty.

I would suggest that simply considering the zero or nil state of any field to be an empty field. So, "" would be empty for a string, and 0 would be empty for an int.

@davecgh
Copy link
Owner

davecgh commented Jan 10, 2015

This is a reasonable option I think. It would be based off the zero value, imo.

@jawspeak
Copy link

Any update or pending PR anyone has been working on this? Would be helpful to omit nil / zero values. Is there a test you'd suggest I look at 1st to get to speed with implementing this?

@davecgh
Copy link
Owner

davecgh commented Nov 26, 2015

I don't believe there is anyone working on it. I'm only in maintenance mode on this at the moment to ensure continues to work as Go is updated.

That said, I would accept a pull request that provides an option for this as I think it could certainly be useful. Spew has extremely thorough tests at the moment (100% coverage across all Go versions), so I think all you'd basically want to do is add tests with the zero value for each of the types there are already there to ensure they are omitted when the option is set.

@ghostsquad
Copy link

just stumbled on wanting to do this exact thing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants