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

Implement omision of zeroed-fields with + flag #69

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

2opremio
Copy link
Contributor

@2opremio 2opremio commented Aug 27, 2020

Fixes #59

This PR binds the '+' formatting flag to omitting empty (zero-valued) struct fields.

@kr kr mentioned this pull request Aug 31, 2020
@2opremio
Copy link
Contributor Author

2opremio commented Sep 9, 2020

@kr friendly ping :)

@2opremio
Copy link
Contributor Author

@kr any chance of taking a look at this anytime soon?

@kr
Copy link
Owner

kr commented Sep 19, 2020

I like the idea of omitting zero fields, since that's pretty common in Go source code to begin with.

But maybe it should not be an option. I'm not sure retaining the ability to print zero fields carries its weight.

What do you think?

@kr
Copy link
Owner

kr commented Sep 19, 2020

Or, if it should be an option, maybe the notation should be % +v (instead of % +#v). I think that would be a little closer to the stdlib behavior of %+v and %#v.

@2opremio
Copy link
Contributor Author

No strong opinions here. I can implement whichever option you prefer. just let me know :)

@2opremio
Copy link
Contributor Author

I have given a Go to % +v (instead of % +#v) and I think it's going to be confusing for the end user (adding a single sign, as already found in the PR, to change the behavior is much more intuitive).

@kr what do you say? It's already been a month since I submitted the PR and I would like it to move forward. Thanks!

@2opremio
Copy link
Contributor Author

2opremio commented Feb 2, 2021

@kr friendly ping

1 similar comment
@2opremio
Copy link
Contributor Author

2opremio commented Jan 7, 2022

@kr friendly ping

@nikolay-turpitko
Copy link

+1 for this feature. Regarding format, I'd omit zero values by default (with %# v) and show them with something like %# 0v (zero padding flag). Or vise versa, if you afraid to introduce breaking change. It both closer to existing format and easier to remember. WDYT?

@2opremio
Copy link
Contributor Author

@kr friendly ping

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 this pull request may close these issues.

Is there a way how I can skip zero values?
3 participants