mapper icon indicating copy to clipboard operation
mapper copied to clipboard

BindDefaultValue

Open rs-frank opened this issue 3 years ago • 3 comments

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) }

rs-frank avatar Jan 26 '21 06:01 rs-frank

Hello @rs-frank, can you add more test cases for other default value types like bool, int, float?

mrwormhole avatar Jan 27 '21 13:01 mrwormhole

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) }

rs-frank avatar Jan 28 '21 08:01 rs-frank

could you merge your commit, and rebase your code onto the develop branch? and I will review it

shyandsy avatar Apr 16 '22 06:04 shyandsy