Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hope gf gen ctrl supports controller template customization #3524

Open
alaywn opened this issue Apr 20, 2024 · 1 comment
Open

Hope gf gen ctrl supports controller template customization #3524

alaywn opened this issue Apr 20, 2024 · 1 comment

Comments

@alaywn
Copy link
Contributor

alaywn commented Apr 20, 2024

Package that You wish to enhance

github.com/gogf/gf/cmd/gf/v2

Enhancement description

gf ctrl命令增加一个参数,可以指定生成controller文件时使用的模板。

目前模板中,controller方法模板内容为:

func (c *{CtrlName}) {MethodName}(ctx context.Context, req *{Version}.{MethodName}Req) (res *{Version}.{MethodName}Res, err error) {
// 这里其实可以写一些样板语法,比如:链路追踪的代码
return nil, gerror.NewCode(gcode.CodeNotImplemented)
}

实际业务中,这个方法中有大量的样板语法,所以希望可以由使用的人来根据需要定制模板

Additional

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


Package that You wish to enhance

github.com/gogf/gf/cmd/gf/v2

Enhancement description

The gf ctrl command adds a parameter to specify the template used when generating the controller file.

In the current template, the controller method template content is:

func (c *{CtrlName}) {MethodName}(ctx context.Context, req *{Version}.{MethodName}Req) (res *{Version}.{MethodName}Res, err error) {
// You can actually write some boilerplate syntax here, such as: link tracking code
return nil, gerror.NewCode(gcode.CodeNotImplemented)
}

In actual business, there is a lot of boilerplate syntax in this method, so we hope that the users can customize the template according to their needs.

Additional

@Issues-translate-bot Issues-translate-bot changed the title 希望 gf gen ctrl 支持 controller 模板定制 Hope gf gen ctrl supports controller template customization Apr 20, 2024
@wln32 wln32 added the CLI about gf cli label Apr 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants