helper/schema: add TypeFloat and Zero value
This commit is contained in:
parent
e61077af1f
commit
cf94a79955
|
@ -31,6 +31,7 @@ const (
|
||||||
TypeInvalid ValueType = iota
|
TypeInvalid ValueType = iota
|
||||||
TypeBool
|
TypeBool
|
||||||
TypeInt
|
TypeInt
|
||||||
|
TypeFloat
|
||||||
TypeString
|
TypeString
|
||||||
TypeList
|
TypeList
|
||||||
TypeMap
|
TypeMap
|
||||||
|
@ -47,6 +48,8 @@ func (t ValueType) Zero() interface{} {
|
||||||
return false
|
return false
|
||||||
case TypeInt:
|
case TypeInt:
|
||||||
return 0
|
return 0
|
||||||
|
case TypeFloat:
|
||||||
|
return 0.0
|
||||||
case TypeString:
|
case TypeString:
|
||||||
return ""
|
return ""
|
||||||
case TypeList:
|
case TypeList:
|
||||||
|
|
|
@ -15,6 +15,7 @@ func TestValueType_Zero(t *testing.T) {
|
||||||
}{
|
}{
|
||||||
{TypeBool, false},
|
{TypeBool, false},
|
||||||
{TypeInt, 0},
|
{TypeInt, 0},
|
||||||
|
{TypeFloat, 0.0},
|
||||||
{TypeString, ""},
|
{TypeString, ""},
|
||||||
{TypeList, []interface{}{}},
|
{TypeList, []interface{}{}},
|
||||||
{TypeMap, map[string]interface{}{}},
|
{TypeMap, map[string]interface{}{}},
|
||||||
|
|
|
@ -4,9 +4,9 @@ package schema
|
||||||
|
|
||||||
import "fmt"
|
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 {
|
func (i ValueType) String() string {
|
||||||
if i < 0 || i+1 >= ValueType(len(_ValueType_index)) {
|
if i < 0 || i+1 >= ValueType(len(_ValueType_index)) {
|
||||||
|
|
Loading…
Reference in New Issue