ITADN

Field helpers generated by GORM cli, donot have the base model defined in a seperated file.

#7797Openyangfanlalala 创建于 2026-05-30
type:missing reproduction steps
Y
yangfanlalalacommented
I define a struct named BaseModel in a seperated file named base_model.go, the struction type BaseModel struct { ID uint64 TenantID uint64 Status string CreatedAt time.Time UpdatedAt time.Time } Then, I define a User model embeding it in user.go . type User struct { BaseModel Username string Remark string } The field helper generated is var User = struct { Username field.String Remark field.String }{ Username: field.String{}.WithColumn("username"), Remark: field.String{}.WithColumn("remark"), } And I use config as the demo shows, but it cannot generate a right result. var _ = genconfig.Config{ ExcludeStructs: []any{BaseModel{}}, } It's not my exception. But when I put BaseModel and user in the same file, it can generate a right helper. My computer : windows11 with an arm cpu. Please help me.
0 条评论