people.go 359 B

123456789101112131415161718192021222324252627
  1. package model
  2. import "fmt"
  3. //接口
  4. type Live interface {
  5. run(i int)
  6. eat(thing string)
  7. }
  8. type People struct {
  9. name string
  10. }
  11. func (p *People) run(i int) {
  12. fmt.Println(p.name, "跑了", i, "米")
  13. }
  14. func (p *People) eat(thing string) {
  15. fmt.Println(p.name, "正在吃", thing)
  16. }
  17. func main() {
  18. peo := People{"derek"}
  19. peo.run(100)
  20. peo.eat("面包")
  21. }