github.com/wawandco/ox@v0.13.6-0.20230809142027-913b3d837f2a/plugins/tools/ox/model/fixer.go (about) 1 package model 2 3 import ( 4 "context" 5 "path/filepath" 6 7 "github.com/wawandco/ox/internal/info" 8 "github.com/wawandco/ox/internal/source" 9 ) 10 11 // Fixer 12 type Fixer struct{} 13 14 func (ef Fixer) Name() string { 15 return "models/fixer" 16 } 17 18 func (ef Fixer) Fix(ctx context.Context, root string, args []string) error { 19 tmpl, err := Templates.ReadFile("templates/models.go.tmpl") 20 if err != nil { 21 return err 22 } 23 24 mod := info.ModuleName() 25 if err != nil { 26 return err 27 } 28 29 filename := filepath.Join(root, "app", "models", "models.go") 30 err = source.Build(filename, string(tmpl), mod) 31 if err != nil { 32 return err 33 } 34 35 return err 36 }