
RunQuery应该返回接口,否则你总是要处理强类型。
AnyDB不是必需的,我为此添加了内容。
AnyResult应该在
bar包中定义或导入其中。
type AnyDB interface { RunQuery() AnyResult}type MySQL struct{}func (m *MySQL) RunQuery() AnyResult { return &MySQLResult{}}type AnyResult interface { Result() string}type MySQLResult struct{}func (r *MySQLResult) Result() string { return "foo"}欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)