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
proposal: strings: add IsEmpty function #33991
Comments
The choices seem to be: len(s) == 0
s == ""
strings.IsEmpty(s) I don't see the advantage of adding another approach that is longer to write and no easier to read. |
@ianlancetaylor |
Constants like |
What approach would you take to check if an integer is zero? Surely you would just write
and not expect a function
Strings also have the added, more "magic" as you put it, mechanism of checking their length. Surely a third way is not required. |
most of the people more inclined towards an existing way, I am closing this issue. |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What did you do?
Try to find better to way to check if the string is empty.
What did you expect to see?
Expecting verbose way to check if the string is empty rather than using,
Len(s) == 0
or
s == ""
The text was updated successfully, but these errors were encountered: