We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
As title said, when you transform int16, int64 or other digital type (not int) to bool, return an error result.
func try() { var i int64 = 1 fmt.Println(cast.ToBool(i)) // false }
because cast only assert int type.
// ToBoolE casts an interface to a bool type. func ToBoolE(i interface{}) (bool, error) { i = indirect(i) switch b := i.(type) { case bool: return b, nil case nil: return false, nil case int: if i.(int) != 0 { return true, nil } return false, nil case string: return strconv.ParseBool(i.(string)) default: return false, fmt.Errorf("unable to cast %#v of type %T to bool", i, i) } }
The text was updated successfully, but these errors were encountered:
Successfully merging a pull request may close this issue.
As title said, when you transform int16, int64 or other digital type (not int) to bool, return an error result.
because cast only assert int type.
The text was updated successfully, but these errors were encountered: