摘要:
package main import "fmt" type Animal struct { Color string } // 继承动物结构体 type Dog struct { Name string Animal } // dog方法 类似类方法 func (d *Dog) speak() s 阅读全文
摘要:
package main import "fmt" type Dog struct { Name string } func (d *Dog) speak() string { return "I am a dog and my name is "+ d.Name } func TestStruct 阅读全文
摘要:
package main import "fmt" type Dog struct { Name string } func TestStruct() { // 方式1 //var dog Dog //dog.Name = "jj" // 方式2 //dog := Dog{Name:"wang"} 阅读全文