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

Debatable functions results #6

Open
bbrodriges opened this issue Dec 11, 2016 · 1 comment
Open

Debatable functions results #6

bbrodriges opened this issue Dec 11, 2016 · 1 comment

Comments

@bbrodriges
Copy link
Contributor

I think it worth to change some functions returned results at some conditions.
Questionable functions:

LowerCase and UpperCase

I think that it is wrong to return true for empty string because it (like Schrödinger's cat) has both states and no state at any time. It is more safe for user program to assume that empty string has not upper nor lower case.
Also, though it can only be applied to unicode strings, function unicode.IsUpper or unicode.IsLower returns error if empty string given: check on play.golang.org

FullWidth, HalfWidth and VariableWidth

In my opinion, even that it is noted in comment string, none of this functions can produce positive result if input string is empty since empty string does not contain any characters at all.

Int

Same thing about Int function. Empty string cannot be valid int in any cases. Even strconv.Atoi will return error in this case: check on play.golang.org.
Float function, on the other hand, is not affected since it uses standard strconv.parseFloat function.

Solution

Since there is a chance that this package is being used in other peoples code and even in wild production I think current commit must be tagged using semver and marked with appropriate comment, describing this situation. After that fixes must be applied and new semver tag must be pushed. It will allow users who use package managers to choose suitable version for their code.

@aliuygur
Copy link
Owner

hello,

I think there is not right way in this case, this is only a choice. But I will keep open this issue for another users' idea.

thank you so much.

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