如题,NewHTTP()函数返回值是一个接口,但是 return 的是一个结构体,凭什么啊?为什么这么做啊?返回值改成*HTTP 有什么区别嘛?求教
type HTTP struct {
outPool utils.OutPool
cfg HTTPArgs
checker utils.Checker
basicAuth utils.BasicAuth
}
func NewHTTP() Service {
return &HTTP{
outPool: utils.OutPool{},
cfg: HTTPArgs{},
checker: utils.Checker{},
basicAuth: utils.BasicAuth{},
}
}
type Service interface {
Start(args interface{}) (err error)
Clean()
}