title: Implications of defining a struct inside a function vs outside?
body: <p>Are there any implications (GC churn, performance, or otherwise) to defining an <code>struct</code> inside a function vs. having it defined outside? For example:</p>
  
  <pre><code>type Outside struct {
    Foo string `json:"foo"`
  }
  
  func SomeFunc(b []byte) error {
    outside := Outside{}
  
    if err := json.NewDecoder(b).Decode(&amp;outside); err != nil {
      return err
    }
  
    ...
  }
  </code></pre>
  
  <p>vs.</p>
  
  <pre><code>func SomeFunc(b []byte) error {
  
    type inside struct {
      Foo string `json:"foo"`
    }
  
    if err := json.NewDecoder(b).Decode(&amp;inside); err != nil {
      return err
    }
  
    ...
  }
  </code></pre>
  
  <p>Would there be any situations where one is preferred over the other?</p>