You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
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
orunicode.IsLower
returns error if empty string given: check on play.golang.orgFullWidth, 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. Evenstrconv.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.
The text was updated successfully, but these errors were encountered: