helper/schema: add TypeFloat and Zero value

This commit is contained in:
Mitchell Hashimoto 2015-01-10 15:57:06 -08:00
parent e61077af1f
commit cf94a79955
3 changed files with 6 additions and 2 deletions

View File

@ -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:

View File

@ -15,6 +15,7 @@ func TestValueType_Zero(t *testing.T) {
}{
{TypeBool, false},
{TypeInt, 0},
{TypeFloat, 0.0},
{TypeString, ""},
{TypeList, []interface{}{}},
{TypeMap, map[string]interface{}{}},

View File

@ -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)) {