cast icon indicating copy to clipboard operation
cast copied to clipboard

cast.ToBool return wrong value for int

Open yibaoren opened this issue 4 years ago • 1 comments

image

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

yibaoren avatar Jun 05 '20 07:06 yibaoren

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.

sgsullivan avatar Jun 25 '20 23:06 sgsullivan