Protobuf Compilation - 图1tip

This feature is available starting from version v2.4.

Introduction

This command is used to compile proto files, generating the corresponding protobuf go files and corresponding controller files.

Command Usage

  1. $ gf gen pb -h
  2. USAGE
  3. gf gen pb [OPTION]
  4. OPTION
  5. -p, --path protobuf file folder path
  6. -a, --api output folder path storing generated go files of api
  7. -c, --ctrl output folder path storing generated go files of controller
  8. -h, --help more information about this command
  9. EXAMPLE
  10. gf gen pb
  11. gf gen pb -p . -a . -p .

Protobuf Compilation - 图2tip

If you are using the framework’s recommended project scaffold and have the make tool installed, you can also use the make pb shortcut command.

Parameter Description:

NameRequiredDefault ValueMeaning
pathNomanifest/protobufPoints to the proto protocol definition file
apiNoapiPoints to the directory where the generated interface files are stored
ctrlNointernal/controllerPoints to the directory where the generated controller files are stored

Precautions

  • When generating controller files, it will automatically detect whether there is already a corresponding interface implementation method. If it already exists, the corresponding interface method will not be regenerated to prevent overwriting.
  • If this command is executed in the proto directory and the specified path directory does not exist, the local proto files will be automatically compiled, and the compiled files will be generated in the current directory with the controller file generation feature automatically disabled.