Linux command
kitex 命令
文件
复制后可按需替换文件名、目录或参数。
常用示例
Generate service code
kitex -module [module] [idl_file.thrift]
Generate client code
kitex -module [module] -client [idl_file.thrift]
Specify service name
kitex -module [module] -service [svc] [idl.thrift]
Use Protobuf
kitex -module [module] [idl.proto]
Specify IDL include path
kitex -module [module] -I [path/to/includes] [idl.thrift]
Reuse existing kitex_gen directory
kitex -module [module] -service [svc] -use [import/path/to/kitex_gen] [idl.thrift]
说明
kitex is a code generation tool for the Kitex high-performance RPC framework, part of ByteDance's open-source CloudWeGo ecosystem. It reads Thrift or Protocol Buffers interface definition language (IDL) files and generates Go scaffolding code for both servers and clients, including service interfaces, request/response types, serialization logic, and a runnable project skeleton. The generated code is designed for building Go microservices with features like connection pooling, load balancing, and circuit breaking built into the Kitex framework. By default, kitex produces both server and client code, but the `-client` flag restricts output to client stubs only. Custom code templates can be provided via the `-template` option to control the structure and style of the generated project.
参数
- -module _NAME_
- Go module name.
- -service _NAME_
- Service name.
- -I _PATH_
- Add search path for IDL includes. Can be specified multiple times.
- -use _PATH_
- Skip generating kitex_gen and use the specified import path instead.
- -v, -verbose
- Output more logs during generation.
- -type _TYPE_
- Specify IDL type when it cannot be detected from the file extension.
- -combine-service
- Combine all services in the IDL into a single service (Thrift only).
- -gen-path _DIR_
- Specify output directory for generated code (default: kitex_gen).
- -thrift _VALUE_
- Pass an argument to the thriftgo compiler.
- -protobuf _VALUE_
- Pass an argument to the protoc compiler.
FAQ
What is the kitex command used for?
kitex is a code generation tool for the Kitex high-performance RPC framework, part of ByteDance's open-source CloudWeGo ecosystem. It reads Thrift or Protocol Buffers interface definition language (IDL) files and generates Go scaffolding code for both servers and clients, including service interfaces, request/response types, serialization logic, and a runnable project skeleton. The generated code is designed for building Go microservices with features like connection pooling, load balancing, and circuit breaking built into the Kitex framework. By default, kitex produces both server and client code, but the `-client` flag restricts output to client stubs only. Custom code templates can be provided via the `-template` option to control the structure and style of the generated project.
How do I run a basic kitex example?
Run `kitex -module [module] [idl_file.thrift]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does -module _NAME_ do in kitex?
Go module name.