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

String IsZero() not behaving correctly || docs mistaken #14

Closed
mixedCase opened this issue Feb 8, 2016 · 2 comments
Closed

String IsZero() not behaving correctly || docs mistaken #14

mixedCase opened this issue Feb 8, 2016 · 2 comments

Comments

@mixedCase
Copy link

The docs state the following about null.String.IsZero:

IsZero returns true for null or empty strings, for future omitempty support. (Go 1.4?)
Will return false s if blank but non-null.

Which looks like a contradictory statement. In a test with an empty string, the latter held true: false is returned if the string is equal to "". Could either the behavior of IsZero() change to return true if string equals empty string or the docs be clarified?

Thanks.

@guregu
Copy link
Owner

guregu commented Feb 28, 2016

Whoops. That was the old behavior in null.v2, if you use v2 you can still get it. Alternatively you can use zero.String and it will have similar semantics. I will fix the docs.

@guregu
Copy link
Owner

guregu commented Feb 28, 2016

Alright, I fixed the docs in aa8aa51.
If you would like null.String to have the behavior you described, consider using null.v2 instead of v3, or using a zero.String instead of a null.String.
null.String's behavior was changed in v3 to make it more consistent with the rest of the null package. See #10 for more info about this. 🙇

@guregu guregu closed this as completed Feb 28, 2016
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

No branches or pull requests

2 participants