title: Flatten a struct and convert it to a map[string]string
body: <p>I have various different nested <code>struct</code>, for example:</p>
  
  <pre><code>type MyInnerType struct {
      hello int
  }
  
  type MyType struct {
      foo   string
      bar   MyInnerType
  }
  </code></pre>
  
  <p>with a declaration like this, for example:</p>
  
  <pre><code>x = &amp;MyType{
      foo: "hi"
      bar: MyInnerType{hello: 1}
  }
  </code></pre>
  
  <p>I would like to convert it into flattened map of <code>map[string]string</code> like this:</p>
  
  <pre><code>{"foo":"hi", "hello":"1"}
  </code></pre>
  
  <p>I imagine this has to be done recursively, but also converting various values into <code>string</code> is an issue. I've found this <a href="https://github.com/fatih/structs" rel="nofollow noreferrer">library</a> to help with it, but have not found any solution.</p>
  
  <p>Is there any library that does this? If not, what can I do for myself to solve this?</p>