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

在使用hex生成同时启用 HTTP 和 RPC 服务的代码时,如何配置自定义模板? #207

Open
AdrianWangs opened this issue Aug 2, 2024 · 1 comment

Comments

@AdrianWangs
Copy link

我的项目的每个微服务都是使用 hex 生成代码的,但是最近发现每次生成代码都有一些重复的自定义配置需要编写,所以想要写一个自己的代码生成模板,但是我发现下载官方的 kitex/server的模板,并结合--hex生成命令时会报错缺少 package.yaml:

[ERROR]/Users/user/go/pkg/mod/github.com/cloudwego/hertz/cmd/[email protected]/thrift/plugin.go:162: generate package failed: init layout config failed, err: read layout config from  ../../idl/tpl/kitex/server/standard/package.yaml failed, err: open ../../idl/tpl/kitex/server/standard/package.yaml: no such file or directory

execute plugin 'hertz' failed: exit status 4

但是我把 hertz 的 package.yaml直接复制进来使用--hex 生成代码又会报错:

cwgo server --type RPC --module github.com/AdrianWangs/ai-nexus/go-service/test-user --server_name test-user-service  --idl ../../idl/user-service.thrift --template ../../idl/tpl/kitex/server/standard --hex
[WARN] stdout:

[WARN] stderr:
panic: runtime error: index out of range [-1]

goroutine 1 [running]:
github.com/cloudwego/kitex/tool/internal_pkg/generator.(*customGenerator).commonGenerate(0xc000057a60, 0xc0007fcbd0)
        /Users/user/go/pkg/mod/github.com/cloudwego/[email protected]/tool/internal_pkg/generator/custom_template.go:149 +0x730
github.com/cloudwego/kitex/tool/internal_pkg/generator.renderFile(0x0?, {0xc0001e484b?, 0xa?}, 0xc0005b6b00?)
        /Users/user/go/pkg/mod/github.com/cloudwego/[email protected]/tool/internal_pkg/generator/custom_template.go:208 +0x5b
github.com/cloudwego/kitex/tool/internal_pkg/generator.(*generator).GenerateCustomPackage(0xc000057c98, 0xc0005b6b00)
        /Users/user/go/pkg/mod/github.com/cloudwego/[email protected]/tool/internal_pkg/generator/custom_template.go:192 +0x18c
github.com/cloudwego/kitex/tool/internal_pkg/pluginmode/thriftgo.Run()
        /Users/user/go/pkg/mod/github.com/cloudwego/[email protected]/tool/internal_pkg/pluginmode/thriftgo/plugin.go:95 +0x4b0
main.kitexPluginMode()
        /Users/user/go/pkg/mod/github.com/cloudwego/[email protected]/cwgo.go:57 +0x90
main.main()
        /Users/user/go/pkg/mod/github.com/cloudwego/[email protected]/cwgo.go:38 +0x28e

execute plugin 'kitex' failed: exit status 2

请问官方能否将这一个相关的模板文件共享出来?

@li-jin-gou
Copy link
Member

我们看下这个问题 @AdrianWangs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants