为什么这不行?
package main import "fmt" type name struct { X string } func main() { var a [3]name a[0] = name{"Abbed"} a[1] = name{"Ahmad"} a[2] = name{"Ghassan"} nameReader(a) } func nameReader(array []name) { for i := 0; i < len(array); i++ { fmt.Println(array[i].X) } }
错误:
.\structtest.go:15: cannot use a (type [3]name) as type []name in function argument