Fallback

The cwgo tool supports fallback function, which can be either Kitex or Hz.

Fallback to Kitex

cwgo fallback kitex [global options] command [command options] [arguments...]

Example

  • Create hello.thrift
// hello.thrift
namespace go hello.example

struct HelloReq {
    1: string Name
}

struct HelloResp {
    1: string RespBody;
}

service HelloService {
    HelloResp HelloMethod(1: HelloReq request);
}
  • Execute Command
cwgo fallback kitex -module {your_module_name} hello.thrift

Kitex specific command reference document

Fallback to Hz

cwgo fallback hz [global options] command [command options] [arguments...]

Example

  • Create hello.thrift
// hello.thrift
namespace go hello.example

struct HelloReq {
    1: string Name (api.query="name");
}

struct HelloResp {
    1: string RespBody;
}


service HelloService {
    HelloResp HelloMethod(1: HelloReq request) (api.get="/hello1");
}(
     api.base_domain="http://127.0.0.1:8888";
 )
  • Execute Command
cwgo fallback hz new -module {your_module_name} -idl hello.thrift

Hz specific command reference document


Last modified April 10, 2024 : fix: hertz template error (#1055) (04145e6)