Hi, new gopher here.
type DBModel interface {
Test() //sample
}
type Product struct {}
func (p Product) Test() {} //sample
type Person struct {}
func (p Person) Test() {} //sample
type Pagination interface {
GetRows() []*T //i want this to allow Product and/or Person
}
type ProductPagination struct {
Rows []*Product
}
type PersonPagination struct {
Rows []*Person
}
func (pagination ProductPagination) GetRows() []*Product {
return pagination.Rows
}
func (pagination PersonPagination) GetRows() []*Person{
return pagination.Rows
}
func Foo(pagination Pagination) {
t := pagination.GetRows() //not working
}
Question: is there an easier/simpler way for Foo to accept any struct that implements Pagination?
Note that in my sample above, the GetRows is not correct since idk yet how declare the type