Skip to content

Conversation

@sgsullivan
Copy link
Contributor

@sgsullivan sgsullivan commented Jun 25, 2020

this value when it comes out of the interface is a float64, and a float64 gets casted to false. Example below demonstrates the issue solved in this PR.

package main

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

func main() {
        template := map[string]interface{}{
                "deprecated": float64(1),
        }
        fmt.Printf("its %t\n", cast.ToBool(template["deprecated"]))
}
go run ../x.go
its false

@sgsullivan sgsullivan requested review from dwburke and jvandellen June 25, 2020 22:01
@dwburke
Copy link
Contributor

dwburke commented Jun 25, 2020

that explains the problem I was having with pat a couple weeks ago! nice catch... you should probably report it as a bug

@sgsullivan
Copy link
Contributor Author

Good idea on the bug report. Looks like this was already (spf13/cast#98) but I did just add a comment there.

@sgsullivan sgsullivan merged commit 5660a42 into master Jun 25, 2020
@sgsullivan sgsullivan deleted the template-list-deprecated-fix branch June 25, 2020 23:16
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 this pull request may close these issues.

3 participants