package main import ( "fmt" ) type TestStruct struct { aa string name string } type Object interface{} func main() { array := []Object{} a := TestStruct{} a.aa = "aaaa" a.name = "name" array = append(array, 1) array = append(array, a) for index, value := range array { fmt.Printf("arr[%d]=%d \n", index, value) } }
有疑问加站长微信联系(非本文作者)