Skip to content

Latest commit

 

History

History
53 lines (41 loc) · 2.55 KB

protobuf.md

File metadata and controls

53 lines (41 loc) · 2.55 KB

ProtoBuf

한국어

Generate

$ oct generate pb --help
Option Env. Variable Description
-i, --input OCTOPUS_INPUT Octopus schema file to read
-o, --output OCTOPUS_OUTPUT Target file
--goPackage OCTOPUS_GO_PACKAGE Protobuf golang package name
-g, --groups OCTOPUS_GROUPS Table groups to generate.
Set multiple groups with comma(,) separated.
-p, --package OCTOPUS_PACKAGE Protobuf package name
-f, --prefix OCTOPUS_PREFIX Proto message name prefix.
Format: <group1>:<prefix1>[,<group2>:<prefix2>]...
Example: group1:prefix1,group2:prefix2
-d, --removePrefix OCTOPUS_REMOVE_PREFIX Prefixes to remove from proto message name.
Set multiple prefixes with comma(,) separated.
--relationTagDecr OCTOPUS_RELATION_TAG_DECR Relation tags decremental from relationTagStart. Default: false
--relationTagStart OCTOPUS_RELATION_TAG_START Relation tags start index. Set -1 to start from last of fields.

Example

$ oct generate pb \
    --input examples/user.json \
    --output output/user.proto \
    --goPackage model \
    --package octopus

Generated *.proto file:

syntax = "proto3";

package octopus;

option go_package = "model";

message Group {
  int64 id = 1;
  string name = 2;
}

message User {
  int64 id = 1;
  string name = 2;
  int64 groupId = 3;
  Group group = 4;
}