Ompluscator / dynamic-struct

Golang package for editing struct's fields during runtime and mapping structs to other structs.
MIT License
672 stars 83 forks source link

Loading the struct from a buffer #3

Closed jeffhu1 closed 5 years ago

jeffhu1 commented 5 years ago

Is it possible to load the struct from a buffer containing the struct fields at the proper locations? I tried to make an array with the dynamic struct as the type but it threw an error. code looks like this

dynStruct := dynamicstruct.NewStruct().AddField(...).Build().New()
buf := make([]dynStruct, len)

Since this didn't work I'm wondering if its possible to overlay the struct over a buffer that I create

Ompluscator commented 5 years ago

Nice point. I plan to add possibility to initiate a slice of dynamic structs and maps of dynamic structs with desired key type. Expectation would be to have it this week.