package repository import ( "gorm.io/gorm" "gorm.io/gorm/schema" ) type MethodInitInterface interface { Init(dbConn *gorm.DB) } type RepoBase[T schema.Tabler] struct { DbConn int ListMethod[T] GetMethod[T] ExistsMethod[T] methods []MethodInitInterface } func (b *RepoBase[T]) InitMethods(dbConn *gorm.DB) { for _, method := range b.methods { method.Init(dbConn) } } func (m *RepoBase[T]) Init(dbConn *gorm.DB) { m.methods = []MethodInitInterface{&m.ListMethod, &m.GetMethod, &m.ExistsMethod} m.InitMethods(dbConn) }