注:
本文代码来自https://zhuanlan.zhihu.com/p/47616970
解释资料来自https://www.jianshu.com/p/d93656cdce0a
先看这一段代码
package main
import (
"fmt"
)
type People interface {
Speak(string) string
}
type Stduent struct{
}
func (stu *Stduent) Speak(think string) (talk string) {
if think == "eat" {
talk = "You are a good boy"
} else {
talk = "hi"