go struct结构

1.自定义数组类型

type dics struct {
        hello string
        id    int
        value float32
    }
//申明变量 为定义的类型,传值
    var a dics
    a.hello = “go语言”
    a.id = 2
    a.value = 1.21

  

2.、自定义变量类型,赋给指针

func main() {
    type dics struct {
        hello string
        id    int
        value float32
    }

    var a dics
    a.hello = "go语言"
    a.id = 2
    a.value = 1.21

    var aa *dics
    aa = &a
    fmt.Println(aa.hello)

}

  

posted @ 2018-12-26 23:41  t_zcx  阅读(161)  评论(0编辑  收藏  举报