helper/schema: add TypeFloat and Zero value
This commit is contained in:
parent
e61077af1f
commit
cf94a79955
|
@ -31,6 +31,7 @@ const (
|
|||
TypeInvalid ValueType = iota
|
||||
TypeBool
|
||||
TypeInt
|
||||
TypeFloat
|
||||
TypeString
|
||||
TypeList
|
||||
TypeMap
|
||||
|
@ -47,6 +48,8 @@ func (t ValueType) Zero() interface{} {
|
|||
return false
|
||||
case TypeInt:
|
||||
return 0
|
||||
case TypeFloat:
|
||||
return 0.0
|
||||
case TypeString:
|
||||
return ""
|
||||
case TypeList:
|
||||
|
|
|
@ -15,6 +15,7 @@ func TestValueType_Zero(t *testing.T) {
|
|||
}{
|
||||
{TypeBool, false},
|
||||
{TypeInt, 0},
|
||||
{TypeFloat, 0.0},
|
||||
{TypeString, ""},
|
||||
{TypeList, []interface{}{}},
|
||||
{TypeMap, map[string]interface{}{}},
|
||||
|
|
|
@ -4,9 +4,9 @@ package schema
|
|||
|
||||
import "fmt"
|
||||
|
||||
const _ValueType_name = "TypeInvalidTypeBoolTypeIntTypeStringTypeListTypeMapTypeSettypeObject"
|
||||
const _ValueType_name = "TypeInvalidTypeBoolTypeIntTypeFloatTypeStringTypeListTypeMapTypeSettypeObject"
|
||||
|
||||
var _ValueType_index = [...]uint8{0, 11, 19, 26, 36, 44, 51, 58, 68}
|
||||
var _ValueType_index = [...]uint8{0, 11, 19, 26, 35, 45, 53, 60, 67, 77}
|
||||
|
||||
func (i ValueType) String() string {
|
||||
if i < 0 || i+1 >= ValueType(len(_ValueType_index)) {
|
||||
|
|
Loading…
Reference in New Issue