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

goctl template --home 指定自定义模板目录不生效 #1330

Closed
leafney opened this issue Dec 15, 2021 · 7 comments
Closed

goctl template --home 指定自定义模板目录不生效 #1330

leafney opened this issue Dec 15, 2021 · 7 comments
Assignees
Labels
kind/need-more-investigation More investigation is needed.

Comments

@leafney
Copy link

leafney commented Dec 15, 2021

我还是用中文描述吧!

Describe the bug

goctl release v1.2.4 使用 --home 指定自定义模板目录不生效
版本:

➜ goctl --version
goctl version 1.2.3-cli darwin/amd64

To Reproduce
Steps to reproduce the behavior, if applicable:

  1. The code is

    goctl api go -api="test.api" -dir="api" -style GoZero --home ./template/1.2.3-cli
  2. The error is

我修改了默认模板中 api 的 handler 和 logic 模板 api/handler.tplapi/logic.tpl ,通过上面的命令生成后发现还是使用的默认自带的模板。
更具体一点,我是参照 https://go-zero.dev/cn/template.html 这个例子,更改了 handler 中的返回格式 将 httpx.OkJson(w, body) 改成了 reponse.Response(w, resp, err) 这种。

开始我以为是目录的问题,然后我就放到了 ~/.goctl 下面,测试发现还是不生效。

后来我又换回了之前使用的 goctl v1.2.1 , 发现这个是生效的。所以怀疑是 v1.2.4 有问题。

Expected behavior
A clear and concise description of what you expected to happen.

Environments (please complete the following information):

  • OS: [macbook 11.4]
  • go-zero version [1.2.4]
  • goctl version [1.2.4]

More description
Add any other context about the problem here.

@kevwan kevwan added the kind/need-more-investigation More investigation is needed. label Dec 15, 2021
@chensylz
Copy link
Contributor

so do I

@kesonan
Copy link
Collaborator

kesonan commented Dec 25, 2021

感谢反馈,这个问题已经发现了,目前我们已经在讨论这个解决方案,目前的解决方案是在通过 --home 指定的目录下需要创建一个与 goctl 版本号的目录来存放你的模板,这样 --home才能生效,如你的 goctl 版本为 1.2.3, 你的自定模板版本应该在 path/to/custom/1.2.3/templates, 那么 --home 指定的值应该为 path/to/custom

@leafney
Copy link
Author

leafney commented Dec 25, 2021

突然有一个想法,是否可以根据goctl的当前版本来自动判断加载哪个目录。或者是,将版本作为一个参数传入。
当然,不清楚你们这样设计的目的是为什么解决什么问题。只是觉得对于开发者来说,在使用上还是越简单越好,可能设计就会比较复杂一些。
谢谢!

kesonan pushed a commit to kesonan/go-zero that referenced this issue Dec 28, 2021
kesonan pushed a commit to kesonan/go-zero that referenced this issue Dec 30, 2021
@kevwan kevwan closed this as completed in 8e9110c Dec 30, 2021
@pengmingfong
Copy link

这个问题在哪个版本解决掉了呀?我go-zero 1.6.3 版本还是有这个问题

@Issues-translate-bot
Copy link

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


In which version has this problem been solved? I still have this problem in go-zero 1.6.3 version

@pengmingfong
Copy link

@kesonan 这个问题在哪个版本解决掉了呀?我go-zero 1.6.3 版本还是有这个问题

@Issues-translate-bot
Copy link

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


@kesonan In which version has this problem been solved? I still have this problem in go-zero 1.6.3 version

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/need-more-investigation More investigation is needed.
Projects
None yet
Development

No branches or pull requests

6 participants