title: How to convert os.File to *multipart.FileHeader in Go?
body: <p>I'm writing test for a function like this.</p>
  <pre class="lang-golang prettyprint-override"><code>type Form struct {
      Message     string
      Attachments []*multipart.FileHeader
  }
  
  func Submit(form *Form) {
      // submit the form
  }
  </code></pre>
  <p>I want to create a <code>Form</code> instance with a slice of *multipart.FileHeader. I have some file that can be used for the test, and I can open them with <code>os.Open()</code>, which returns <code>*os.File</code>. I also tried to use <code>&amp;multipart.FileHeader{Filename: &quot;/path/to/file&quot;}</code>, but that didn't work (cannot be opened). How can I convert <code>*os.File</code> to <code>*multipart.FileHeader</code> in Go? I do know I can do that with the <code>multipart.NewWriter()</code> method and mock an http request, but I want to know whether there's a simpler way.</p>