在Golang中将named-type map [string] string转换成普通的一个

I have a map of type set, which is actually a map[string]string. However, passing it to a function which accepts a map[string]string fails, because Go does not recognize set as one.

However, I fail to convince the compiler it is one. Is there any way to resolve this, without looping and copying?

package main

import (
    "fmt"
)

type name string
type field string

type set map[name]field      // map[string]string after all
type plain map[string]string // also map[string]string

func main() {
    var typed = set{"hi": "ho"} // map[string]string?

    back := plain(typed)  // cannot convert typed (type set) to type plain
    back := typed.(plain) // invalid type assertion: typed.(plain) (non-interface type set on left)

    echo(back)
}

func echo(in map[string]string) {
    fmt.Println(in)
}

You could do this using the unsafe package.

Note: I don't think this would necessarily be a good idea, and probably the right way would be to just iterate and copy, but since it does answer the question asked...

var typed = set{"hi": "ho"} // map[string]string?
p := unsafe.Pointer(&typed)
var back plain
back = *(*plain)(p)

Playground: https://play.golang.org/p/yienSuJSnQU