Ompluscator / dynamic-struct

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

Not an issue per se #1

Closed pitakill closed 5 years ago

pitakill commented 5 years ago

Nice piece of software you have here!

I've got a doubt about if is possible to have methods on the dynamic structs built with this library. Or in other words, if the dynamic structs can implement a interface

Some light about it will be awesome

Ompluscator commented 5 years ago

Thx! I'm not completely sure about about interface implementation, but I had some thoughts to work on that, maybe even in next version :)

Ompluscator commented 5 years ago

I've tried many different approaches. Last one was by trying to attach anonymous field which implements some interface. Unfortunately, right now thats not possible: https://github.com/golang/go/issues/23063

For now, I would suggest usage of ToStruct method from reader - it would be possible to map complete dynamic struct to some struct, which than implements some interface.