github.com/jhump/protoreflect@v1.16.0/desc/protoprint/testfiles/desc_test_comments-sorted.proto (about)

     1  // Syntax comment...
     2  syntax = "proto2"; // Syntax trailer.
     3  
     4  // And now the package declaration
     5  package foo.bar;
     6  
     7  import "desc_test_options.proto";
     8  
     9  import public "google/protobuf/empty.proto";
    10  
    11  // option comments FTW!!!
    12  option go_package = "github.com/jhump/protoreflect/internal/testprotos";
    13  
    14  message AnEmptyMessage {
    15  }
    16  
    17  // We need a request for our RPC service below.
    18  message Request {
    19     option deprecated = true; // deprecated!
    20  
    21     // lead mfubar
    22     option (testprotos.mfubar) = true; // trailing mfubar
    23  
    24     // A field comment
    25     repeated int32 ids = 1 [
    26        json_name = "|foo|",
    27        packed = true,
    28        (testprotos.ffubar) = "abc",
    29        (testprotos.ffubarb) = "xyz"
    30     ]; // field trailer #1...
    31  
    32     // label comment
    33     optional string name = 2 [default = "fubar"];
    34  
    35     // Group comment with emoji 😀 😍 👻 ❤ 💯 💥 🐶 🦂 🥑 🍻 🌍 🚕 🪐
    36     optional group Extras = 3 {
    37        // trailer for Extras
    38  
    39        option no_standard_descriptor_accessor = false;
    40  
    41        // this is a custom option
    42        option (testprotos.mfubar) = false;
    43  
    44        optional double dbl = 1;
    45  
    46        optional float flt = 2;
    47  
    48        // Leading comment...
    49        optional string str = 3; // Trailing comment...
    50     }
    51  
    52     // can be this or that
    53     oneof abc {
    54        // trailer for oneof abc
    55  
    56        string this = 4;
    57  
    58        int32 that = 5;
    59     }
    60  
    61     // can be these or those
    62     oneof xyz {
    63        // whoops?
    64        option (testprotos.oofubar) = "whoops, this has invalid UTF8! \274\377";
    65  
    66        string these = 6;
    67  
    68        int32 those = 7;
    69     }
    70  
    71     // map field
    72     map<string, string> things = 8;
    73  
    74     enum MarioCharacters {
    75        // trailer for enum
    76  
    77        // allow_alias comments!
    78        option allow_alias = true;
    79  
    80        option (testprotos.efubar) = 123;
    81  
    82        option (testprotos.efubars) = -321;
    83  
    84        SNIFIT = -101;
    85  
    86        MARIO = 1 [
    87           (testprotos.evfubar) = 278,
    88           (testprotos.evfubars) = -314
    89        ];
    90  
    91        LUIGI = 2 [
    92           (testprotos.evfubaru) = 200,
    93           (testprotos.evfubaruf) = 100
    94        ];
    95  
    96        PEACH = 3;
    97  
    98        BOWSER = 4;
    99  
   100        WARIO = 5;
   101  
   102        WALUIGI = 6;
   103  
   104        HEY_HO = 7;
   105  
   106        SHY_GUY = 7 [(testprotos.evfubarsf) = 10101];
   107  
   108        KAMEK = 8;
   109  
   110        MAGIKOOPA = 8;
   111     }
   112  
   113     extensions 100 to 200;
   114  
   115     extensions 201 to 250 [
   116        (testprotos.exfubar) = "splat!",
   117        (testprotos.exfubarb) = "\000\001\002\003\004\005\006\007"
   118     ];
   119  
   120     reserved 10 to 20, 30 to 50;
   121  
   122     reserved "bar", "baz", "foo";
   123  }
   124  
   125  // Service comment
   126  service RpcService {
   127     // service trailer
   128     // that spans multiple lines
   129  
   130     option deprecated = false; // DEPRECATED!
   131  
   132     // option that sets field
   133     option (testprotos.sfubar) = { id: 100, name: "bob" };
   134  
   135     option (testprotos.sfubare) = VALUE;
   136  
   137     // Method comment
   138     rpc StreamingRpc ( stream Request ) returns ( Request ); // compact method trailer
   139  
   140     rpc UnaryRpc ( Request ) returns ( google.protobuf.Empty ) {
   141        // trailer for method
   142  
   143        // this RPC is deprecated!
   144        option deprecated = true;
   145  
   146        option (testprotos.mtfubar) = 12.340000;
   147  
   148        option (testprotos.mtfubard) = 123.456000;
   149     }
   150  }
   151  
   152  extend Request {
   153     // trailer for extend block
   154  
   155     // comment for guid1
   156     optional uint64 guid1 = 123;
   157  
   158     // ... and a comment for guid2
   159     optional uint64 guid2 = 124;
   160  }