package rest_gorm import ( "reflect" "testing" "git.ali33.ru/fcg-xvii/rest" ) type ExtSize struct { ID int } type NameExtChild struct { ID int Name string Size *ExtSize `rest:"ext"` } type NameExt struct { ID int Name string ExtPointer *NameExtChild `rest:"ext"` ExtSlice []NameExtChild `rest:"ext"` ExtStruct NameExtChild `rest:"ext"` } func TestNamesExt(t *testing.T) { //i := 10 //r := reflect.ValueOf(&i) r := reflect.ValueOf(&NameExt{}) //rType := reflect.TypeOf(r.Type()) res, err := namesExt(r) if err != nil { t.Fatal(err) } for _, v := range res { t.Log(v.eName, reflect.ValueOf(v.eValue).Elem().Type()) } t.Log(res) } func TestPreload(t *testing.T) { fields := rest.FieldList{ &rest.Field{ Name: "ExtStruct", Names: rest.FieldList{ &rest.Field{ Name: "Size", }, }, }, &rest.Field{ Name: "ExtSlice", }, &rest.Field{ Name: "ExtPointer", Names: rest.FieldList{ &rest.Field{ Name: "Size", }, }, }, } val := &NameExt{} _, err := Preload(val, fields, nil) if err != nil { t.Fatal(err) } }