reflections icon indicating copy to clipboard operation
reflections copied to clipboard

Struct enmbeeded

Open xellDart opened this issue 8 years ago • 3 comments

Is possible to get embeeded struct field for example struct A { Person Person }

struct Person { fields.... }

I need to get person fields without use direct struct

xellDart avatar Jan 21 '18 00:01 xellDart

this is a common use case, hope we can support it

TateDeng avatar Jan 11 '23 03:01 TateDeng

Hey @TateDeng thanks for bringing this to my attention 🙇🏻

I'll try to find time to look into it, indeed. In the meantime, if you have ideas of how to contribute the feature yourself, feel free to open a pr 👍🏻

oleiade avatar Jan 11 '23 12:01 oleiade

Hey @TateDeng thanks for bringing this to my attention 🙇🏻

I'll try to find time to look into it, indeed. In the meantime, if you have ideas of how to contribute the feature yourself, feel free to open a pr 👍🏻

@oleiade I was thinking to support . in the name, tagValue params of all exported functions, e.g. MyEmbeddedStruct.EmbeddedField for below case, what do you think?

type MyStruct struct {
	MyEmbeddedStruct
	FirstField  string `matched:"first tag"`
	SecondField int    `matched:"second tag"`
	ThirdField  string `unmatched:"third tag"`
}

type MyEmbeddedStruct struct {
	EmbeddedField string
}

TateDeng avatar Jan 12 '23 03:01 TateDeng