1. package main
    2. import "fmt"
    3. type cat struct {
    4. color string
    5. gender byte
    6. age int
    7. }
    8. func (d cat) say() {
    9. fmt.Println(d.color, d.gender, d.age) //可用:fmt.Printf("%s %d %d", d.color, d.gender, d.age)
    10. }
    11. func main() {
    12. var b cat
    13. b.color = "yellow"
    14. b.say()
    15. }
    1. yellow 0 0