标签:name 指针 数据结构 nbsp class imp Golan func 基本
1 goalng struct
1.1 var s1 student
1.2 s2 := student {"zhou", 33}
1.3 s3 := student {Name:"zhou", Age:33}
1.4 s4 := new(student) // 包含空值的指针
1.5 s5 := make([]strudent, 2) // student slice
package main import ( "fmt" ) type student struct { Name string Age int } func main() { //1.1 var s student s.Name = "zhang" s.Age = 18 fmt.Println(s) //1.2 s2 := student{"zhou", 30} fmt.Println(s2) //1.3 s3 := student{ Name: "zha", Age: 33, } fmt.Println(s3) //1.4 s4 := new(student) s4.Name = "www" s4.Age = 18 fmt.Println(s4) //1.5 s5 := make([]student, 2) fmt.Println(s5) }
标签:name 指针 数据结构 nbsp class imp Golan func 基本
原文地址:https://www.cnblogs.com/learn-ops/p/9655795.html