标签:func name wan sts pre fun import 指针 package
package main import "fmt" type Dog struct { Name string } func TestStruct() { // 方式1 //var dog Dog //dog.Name = "jj" // 方式2 //dog := Dog{Name:"wang"} //方式3 var dog = new(Dog) // 返回的是指针 dog.Name = "aa" fmt.Println(dog) } func main() { TestStruct() }
标签:func name wan sts pre fun import 指针 package
原文地址:https://www.cnblogs.com/php-linux/p/13057521.html