1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
| type Person struct { Name string Age int Sex string }
func main() { var p1 Person = Person{} fmt.Println(p1) var p2 Person = Person{Name: "Gary Wang", Age: 33, Sex: "nan"} fmt.Println(p2) p3 := Person{"Gary Wang", 33, "nan"} fmt.Println(p3) var p4 *Person = &Person{ Name: "Gary Wang", Age: 33, Sex: "nan", } fmt.Println(p4) }
|