go 基础 结构体 接口

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")
}

猜你喜欢

转载自www.cnblogs.com/ligenyun/p/10896620.html