-
Notifications
You must be signed in to change notification settings - Fork 367
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
Comments
This is a reasonable option I think. It would be based off the zero value, imo. |
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? |
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. |
just stumbled on wanting to do this exact thing. |
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.
The text was updated successfully, but these errors were encountered: