Привет. Осваиваю генерацию запросов. Делаю по ману так:
type Person struct {
gorm.Model
Name string `"gorm:not null"`
Age int
}
type IPerson interface {
FilterWithName(name string) (gen.T, error)
}
gormDb, err := gorm.Open(sqlite.Open("test.gorm"), &gorm.Config{})
if err != nil {
panic(err)
}
g := gen.NewGenerator(gen.Config{
OutPath: "./query",
Mode: gen.WithoutContext | gen.WithDefaultQuery | gen.WithQueryInterface,
})
err = gormDb.AutoMigrate(model.Person{})
if err != nil {
fmt.Println(err)
}
g.UseDB(gormDb)
g.ApplyBasic(model.Person{})
g.ApplyInterface(func(model.IPerson) {}, model.Person{})
g.Execute()