title: "Cannot use variable of type []struct as []interface" while spreading
body: <p><strong>Prototype function</strong></p>
  
  <pre class="lang-golang prettyprint-override"><code>func test(i ...interface{}) {
      // Code here
  }
  </code></pre>
  
  <p><strong>Intended use</strong></p>
  
  <pre class="lang-golang prettyprint-override"><code>type foo struct {
      // Fields
  }
  
  foos := []foo{
      // foo1, foo2 ...
  }
  
  test(foos...) // ERROR
  test(foos[1], foos[2], ...) // OK
  </code></pre>
  
  <p><strong>Error</strong></p>
  
  <blockquote>
    <p>cannot use foos (variable of type []foos) as []interface{} value in argument to test</p>
  </blockquote>
  
  <h1>Description</h1>
  
  <p>The intended use is to be used like the built-in function <code>append()</code>.</p>
  
  <p><a href="https://golang.google.cn/pkg/builtin/#append" rel="nofollow noreferrer">https://golang.google.cn/pkg/builtin/#append</a></p>
  
  <pre><code>func append(slice []Type, elems ...Type) []Type
  </code></pre>
  
  <p>Although, as I've seen <code>append()</code> doesn't use <code>interface{}</code>, which is strange, since anywhere that I searched all people say to use <code>interface{}</code> when you don't know the type. But they don't.
  Nope, <code>append()</code> uses a "build-in" type called <code>Type</code>, which apparently the docs say that it's a <code>int</code>. Although, I cannot use it. There isn't such type. And neither I would know how to use it if there was.</p>
  
  <p><a href="https://golang.google.cn/pkg/builtin/#Type" rel="nofollow noreferrer">https://golang.google.cn/pkg/builtin/#Type</a></p>
  
  <pre><code>type Type int
  </code></pre>
  
  <p>So, I'm very confused here. </p>
  
  <h1>Questions</h1>
  
  <ol>
  <li><p>Why does the spread operator not work as intended? For example, in Javascript the spread operator just spreads the array into items. But in Golang it seems like it <strong>keeps the same array parameter type</strong> as it is but gives the compiler later an instruction to spread it. Which is odd.</p></li>
  <li><p>Are we even able to make similar custom mechanisms like <code>append()</code> at all? Or am I a dummy and I'm using something wrong anyway?</p></li>
  </ol>