0

Playground for my problem: https://play.golang.org/p/rVwEaxpkJGL

I have struct like

type SimpleBbInput struct {
  MyInput  struct {
     Num struct {
        val int
     } 
  } 
  HisInput string
  HerInput uint8 
}

I will store the field name and type in a map[string]interface{}, result like

map[HerInput:uint8 MyInput:map[Num:map[val:int]] HisInput:string]

My question is how to using this map to get back SimpleBbInput without knowing this struct.

Thanks

icelemon
  • 827
  • 2
  • 11
  • 23
  • I would suggest neither to use reflection, nor interface{}. Use concrete types for your concrete problem. That will make it much easier, not only for you to write it but for you to read it in three weeks as well. – gonutz Jul 22 '18 at 06:54
  • Thanks gonutz, could you give me an example or go playground – icelemon Jul 24 '18 at 19:38
  • I do not even know what your concrete problem is, please elaborate on **why** you want to do this. – gonutz Jul 24 '18 at 19:49

0 Answers0