Basic commands

Use cwgo server -h to view help commands for generating server code.

   cwgo server - generate RPC or HTTP server

                   # Generate RPC server code 
                   cwgo server --type RPC --idl  {{path/to/IDL_file.thrift}} --service {{svc_name}}

                   # Generate HTTP server code 
                   cwgo server --type HTTP --idl  {{path/to/IDL_file.thrift}} --service {{svc_name}}

   cwgo server [command options] [arguments...]

   --service value                                                              Specify the service name.
   --type value                                                                 Specify the generate type. (RPC or HTTP) (default: "RPC")
   --module value, --mod value                                                  Specify the Go module name to generate go.mod.
   --idl value                                                                  Specify the IDL file path. (.thrift or .proto)
   --template --template***/cwgo_template.git               Specify the template path. Currently cwgo supports git templates, such as --template***/cwgo_template.git
   --registry value                                                             Specify the registry, default is None.
   --proto_search_path value, -I value [ --proto_search_path value, -I value ]  Add an IDL search path for includes.
   --pass value [ --pass value ]                                                Pass param to hz or Kitex.
   --verbose                                                                    Turn on verbose mode. (default: false)
   --hex                                                                        Add HTTP listen for Kitex. (default: false)
   --help, -h                                                                   show help (default: false)


  • service: Specify the service name for functions such as service registration and discovery
  • type: Specify the generation type, support parameters RPC and HTTP, default to RPC
  • module/mod: Specify the go mod name, which must be specified outside of GOPATH. In GOPATH, the default name is the path relative to GOPATH
  • idl: Specify the main IDL file path
  • template: Specify a custom template that supports local and git reading. Please refer to the usage for details Template Extension
  • registry: The specified service registration component is currently only useful for RPC types and supports parameters ZK, NACOS, ETCD, and POLARIS
  • proto_search_path/I: Add IDL search path, only effective for pb
  • pass: The parameters passed to hz and kitex, such as the handler dir parameter passed to hz, should be entered as –pass “–handler_dir ./handler”. Parameters passed to the tool, hz reference doc, kitex reference doc
  • hex: Enable both HTTP and RPC services on the same port. For usage examples, please refer to hex usage example
  • verbose: Turn on redundant logging mode
  • help: help command