golang之void*类型可变数组例子

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)
    }
}

 

posted @ 2013-11-16 16:35  自由出土文物  阅读(1416)  评论(0编辑  收藏  举报