cloudwego / kitex

Go RPC framework with high-performance and strong-extensibility for building micro-services.
https://www.cloudwego.io
Apache License 2.0
6.92k stars 806 forks source link

自定义模板生成报错 #1358

Open XiaoYi-byte opened 3 months ago

XiaoYi-byte commented 3 months ago

Describe the bug 使用kitex自定义模板生成报错 img_v3_02b7_b2f0ec07-1909-4ba0-9312-2793085d6e6g 生成的目录结构 img_v3_02b7_cf7baa41-65a9-465e-96ed-8a798c67faag _default.go中的内容 image

PackageInfo.RealServiceName由tool/internal_package/generator/generator.go中的Config.ServiceName赋值,Config.ServiceName是通过-service参数指定的,但是-service参数和-template-dir是不能同时指定的,这好像矛盾了?

To Reproduce 创建两个文件夹tpl和idl,在idl中创建hello.thrift,tpl中创建default.yaml

// hello.thrift
namespace go api

struct Request {
    1: string message
}

struct Response {
    1: string message
}

service Hello {
    Response echo(1: Request req)
}

tpl/default.yaml用的是https://github.com/cloudwego/cwgo/blob/main/tpl/kitex/client/standard/default_tpl.yaml 运行命令 kitex -module github.com/xxx/demo -service demo -template-dir tpl idl/hello.thrift Expected behavior

正确生成自定义模板

Kitex version:

v0.9.1

HeyJavaBean commented 3 months ago

cwgo这里的例子单独使用会有点问题。模板相关功能近期我们有计划整体优化+完善文档,后续我们会统一处理