@@ -20,6 +20,7 @@ type Context struct {
20
20
Easy bool
21
21
Output string
22
22
Cfg * config.Config
23
+ PackageName string
23
24
}
24
25
25
26
// Do executes model template and output the result into the specified file path
@@ -61,6 +62,7 @@ func generateModel(ctx *Context) error {
61
62
"lowerType" : stringx .From (t ).Untitle (),
62
63
"Cache" : ctx .Cache ,
63
64
"version" : version .BuildVersion ,
65
+ "PackageName" : ctx .PackageName ,
64
66
}, output , true ); err != nil {
65
67
return err
66
68
}
@@ -88,6 +90,7 @@ func generateCustomModel(ctx *Context) error {
88
90
"snakeType" : stringx .From (t ).ToSnake (),
89
91
"Cache" : ctx .Cache ,
90
92
"Easy" : ctx .Easy ,
93
+ "PackageName" : ctx .PackageName ,
91
94
}, output , false )
92
95
if err != nil {
93
96
return err
@@ -112,6 +115,7 @@ func generateTypes(ctx *Context) error {
112
115
output := filepath .Join (ctx .Output , fn + ".go" )
113
116
if err = util .With ("model" ).Parse (text ).GoFmt (true ).SaveTo (map [string ]any {
114
117
"Type" : stringx .From (t ).Title (),
118
+ "PackageName" : ctx .PackageName ,
115
119
}, output , false ); err != nil {
116
120
return err
117
121
}
@@ -128,5 +132,7 @@ func generateError(ctx *Context) error {
128
132
129
133
output := filepath .Join (ctx .Output , "error.go" )
130
134
131
- return util .With ("error" ).Parse (text ).GoFmt (true ).SaveTo (ctx , output , false )
135
+ return util .With ("error" ).Parse (text ).GoFmt (true ).SaveTo (map [string ]any {
136
+ "PackageName" : ctx .PackageName ,
137
+ }, output , false )
132
138
}
0 commit comments