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)

}

  

猜你喜欢

转载自www.cnblogs.com/Jack-cx/p/10182643.html