The following code
package main
import "strings"
import "fmt"
type Foo string
const (
Bar Foo = "bar"
Snafu = "snafu"
Foobar = "foobar"
)
var Foos = []Foo{Bar, Snafu, Foobar}
func main() {
fmt.Println("Foos: " + strings.Join(Foos, ","))
}
Produces this error:
./test.go:17: cannot use Foos (type []Foo) as type []string in argument to strings.Join
This makes sense since Foo is not string but it is derived from string. Is there any way to coerce the "[]Foo" to "[]string" without copying?