title: How to initialize a array of interface in golang?
body: <p>I want to initialize a map containing a list of interface without having to add them one by one: </p>
  
  <pre><code>type Pixel struct {
      X float64
      Y float64
  }
  
  type Vertex struct {
      X float64
      Y float64
      Z float64
  }
  type testpair struct {
      filename       string
      values     []interface{}
  }
  var tests = map[string]testpair{
     "test1": {
                 filename: "file1.csv",
                 values:  []Pixel{
                             {X: 12.5, Y: 23.4},
                             {X: 17.2, Y: 7.9},
                        }
              },
     "test2": {
                 filename: "file2.csv",
                 values:  []Vertex{
                             {X: 10.7, Y: 13.3, Z: 25.1},
                             {X: 18.3, Y: 16.9, Z: 16.4},
                        }
              }, 
  }
  </code></pre>
  
  <p>The compiler would output such an error:</p>
  
  <blockquote>
    <p>cannot use []Pixel literal (type []Pixel) as type []interface {} in field value</p>
  </blockquote>
  
  <p>If I switch []interface{} to []Pixel, I can initialize the map but I can do it only with a unique type Pixel or Vertex.</p>
  
  <p>Is there a way to force the compiler to accept array initialization with a specific struct while declaring it as an array of interface? </p>