package School type SchoolModel struct { Name string Address string StudentCount int Is985 bool } type ISchoolDal interface { GetList() Add() Delete() }
package School type SchoolDal struct { } func (o *SchoolDal) GetList() []SchoolModel { var result []SchoolModel if (result == nil) { println("切片是空的") } var t = SchoolModel{"江西财大", "南昌市", 1000, false} var t2 = SchoolModel{"江西财大2", "南昌市", 1000, false} result = append(result, t) result = append(result, t2) return result } func (o *SchoolDal) Add(m SchoolModel) { println("这里是Add") } func (o *SchoolDal) Delete(m SchoolModel) { println("这里是Delete") }
原文:https://www.cnblogs.com/ligenyun/p/10896620.html