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

cast.ToBool return wrong value for int #98

Closed
yibaoren opened this issue Jun 5, 2020 · 1 comment · Fixed by #153
Closed

cast.ToBool return wrong value for int #98

yibaoren opened this issue Jun 5, 2020 · 1 comment · Fixed by #153

Comments

@yibaoren
Copy link

yibaoren commented Jun 5, 2020

image

ToBoolE function can not recognize int64 nor int32, which result in false return
I hope it will be fixed soon.

@sgsullivan
Copy link

I believe I also ran into this issue, for example:

package main

import (
        "fmt"
        "github.com/spf13/cast"
)

func main() {
        fmt.Printf("its %t\n", cast.ToBool(float64(1)))
}

prints its false. I've worked around it by casting to an int before bool.

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

Successfully merging a pull request may close this issue.

2 participants