title: Pass a struct to a function as a parameter and return a slice of the corresponding struct
body: <p>I am trying to write a function which can be used by different structs.
  The return of the function has to be a slice of the corresponding struct.
  Thus I need a function which accept a struct as a parameter and return a slice.
  My code somehow looks like this but I have no idea how can I wrap it as a function?</p>
  
  <pre><code>type name struct{
     FirstName string `xml:"firstName"`
     LastName string `xml:"lastName"`
    }
  
  fileList := TreeTraversal(".")
      var a name
      var b []name 
  
  
  for i := 0; i &lt; len(fileList); i++{
      fileByte, _ := ioutil.ReadFile(fileList[i])
  
      xml.Unmarshal(fileByte, &amp;a)
      b = append(b, a)
  }
  </code></pre>
  
  <p>As far as I know I can pass a struct to a function as an interface, but I have no idea about the return type? </p>