mapper
mapper copied to clipboard
BindDefaultValue
type Info struct {
Ext string d:"aaa"
Name string d:"123"
}
type ShowInfo struct {
Name string d:"name"
Info
CreateTime time.Time d:"2020-01-02 03:04:01"
}
func TestBindDefaultValue(t *testing.T) { var s ShowInfo BindDefaultValue(&s) log.Printf("%+v", s) }
Hello @rs-frank, can you add more test cases for other default value types like bool, int, float?
Hello @rs-frank, can you add more test cases for other default value types like bool, int, float?
func (s InfoForDefaultValueFunc) Default() reflect.Value {
return reflect.ValueOf(InfoForDefaultValueFunc{Name: "test name"})
}
type InfoForDefaultValueFunc struct {
Ext string d:"aaa"
Name string d:"123"
}
type Info struct {
Ext string d:"aaa"
Name string d:"123"
BoolFalse string d:"false"
BoolTrue string d:"true"
Float float32 d:"12.21"
Float64 float64 d:"12.51"
Number int d:"12"
}
type ShowInfo struct {
Name string d:"name"
Info
InfoForDefaultValueFunc InfoForDefaultValueFunc
CreateTime time.Time d:"2020-01-02 03:04:01"
}
func TestBindDefaultValue(t *testing.T) { var s ShowInfo BindDefaultValue(&s) data, _ := json.Marshal(s) log.Printf("%s", data) }
could you merge your commit, and rebase your code onto the develop branch? and I will review it