feat(cmd/gf): improve and enhance gen ctrl #4325
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
介绍
有时候某些项目没有达到要使用大仓模式的程度,使用单仓便可以完成业务。
但是
gf gen ctrl只能支持module/version这种目录,譬如user/v1,像api/app/user/v1,api/admin/admin/v1这种接口便无能为力。本
PR改进了生成模式,现在使其可以更灵活的生成控制器,包括多级目录生成。例子
在
api下定义了app和admin两个模块,其中app下又定义了/user/v1和/user/user_ext/v1,最后生成如红框所示:这是一个复杂的例子,用来检测代码的健壮性。
在真实的项目中,应该类似
api/app/user/v1,api/app/user_ext/v1。其他
/testdata/genctrl和/testdata/genctrl-merge中,现在更改为/testdata/genctrl/default和/testdata/genctrl/merge;gfile.Remove。增进来源:Issue和官网评论