LinuxCommandLibrary

kitex

Generate code for Kitex RPC framework

TLDR

Generate client codes when a project is in $GOPATH

$ kitex [path/to/IDL_file.thrift]
copy

Generate client codes when a project is not in $GOPATH
$ kitex -module [github.com/xx-org/xx-name] [path/to/IDL_file.thrift]
copy

Generate client codes with protobuf IDL
$ kitex -type protobuf [path/to/IDL_file.proto]
copy

Generate server codes
$ kitex -service [svc_name] [path/to/IDL_file.thrift]
copy

SYNOPSIS

kitex [new|generate|lint|module|clean] [options] [arguments]

PARAMETERS

new <project-name>
    Scaffold a new Kitex project with default or custom template.

-t, --type=<thrift|protobuf|protobuf-swagger>
    IDL file type (default: thrift)

-f, --file=<file>
    Path to input IDL file.

-o, --out=<dir>
    Output directory for generated code.

-m, --module=<name>
    Go module name for generated code.

--tpl=<template>
    Project template name (default: default)

--path=<path>
    Custom path mapping for code generation.

lint <file>
    Lint and validate IDL file syntax.

module add <path>
    Add dependency to go.mod.

clean
    Remove all generated Kitex files.

-h, --help
    Show command help.

-v, --version
    Print Kitex tool version.

DESCRIPTION

The kitex command is the official CLI tool for Kitex, a high-performance, extensible Golang RPC framework developed by CloudWeGo (ByteDance microservices team).

It simplifies microservice development by scaffolding projects, generating optimized Go client/server code from IDL files (Thrift, Protobuf, or Protobuf-Swagger), linting IDL definitions, managing Go modules, and cleaning generated artifacts.

Kitex excels in cloud-native environments, offering features like zero-reflection serialization, adaptive load balancing, circuit breaking, and seamless integration with etcd, Consul, and other service discovery tools. The tool ensures type-safe, efficient code generation, reducing boilerplate and boosting performance for high-throughput services.

Ideal for scalable distributed systems, kitex supports both Thrift and Protobuf IDLs, with extensive customization via options for paths, modules, and plugins.

CAVEATS

Requires Go 1.17+ installed; install via go install github.com/cloudwego/kitex-tools/cmd/kitex@latest. Not included in standard Linux distros. IDL files must be valid Thrift/Protobuf.

INSTALLATION

go install github.com/cloudwego/kitex-tools/cmd/kitex@latest
Add $GOPATH/bin or $GOROOT/bin to PATH.

EXAMPLE

kitex new myservice # Scaffold project
kitex generate -type thrift -file hello.thrift # Generate code

HISTORY

Open-sourced in 2021 by ByteDance as part of CloudWeGo; evolved from internal tools for high-scale microservices. Latest v0.12+ adds Protobuf-Swagger support and enhanced linting.

SEE ALSO

go(1), protoc(1)

Copied to clipboard