boolval

boolval

[code=golang]
func boolval(val interface{}) bool {
    switch v := val.(type) {
    case bool:
        return v
    case int:
        return v != 0
    case float64:
        return v != 0
    case string:
        return v != "" && v != "0" && v != "false"
    case nil:
        return false
    default:
        return false
    }
}
[/code]