Can't cast interface{} to []map[string]interface{} directly : <p>I have method which accepts <code>map[string]interface{}</code> parameters (it comes from parsed YAML file):</p>

<pre class="lang-golang prettyprint-override"><code>func load(params map[string]interface{}) error {
}
</code></pre>

<p>This method is trying to extract one element from <code>params</code> and cast it to <code>map[string]interface{}</code>:</p>

<pre class="lang-golang prettyprint-override"><code>if tmp, has := params["badges"]; has {
    if badges, ok := tmp.([]map[string]interface{}); ok {
       // ...
    } else {
        return fmt.Errorf("expected []map[string] but was: %T", tmp)
    }
}
</code></pre>

<p>When I run this method with correct <code>params</code> (with element <code>badges</code> of type <code>[]map[string]string</code>) it fails with error:</p>

<blockquote>
  <p>expected []map[string] but was: []interface {}</p>
</blockquote>

<p>But if I go through all items manually and cast them one by one, it will be OK:</p>

<pre class="lang-golang prettyprint-override"><code>lst := tmp.([]interface{})
ifaces := make([]map[interface{}]interface{}, len(lst), len(lst))
for pos, item := range lst {
    ifaces[pos] = item.(map[interface{}]interface{})
}
badges := make([]map[string]interface{}, len(lst), len(lst))
for pos, mp := range ifaces {
    badges[pos] = make(map[string]interface{})
    for k, v := range mp {
        badges[pos][k.(string)] = v
    }
}
</code></pre>

<p>But the second solution looks overcomplicated for just casting one type to another. Is it possible to cast <code>interface{}</code> to list of maps simpler?</p>
