In Protocol Buffers, how to import a file from the upper level directory?

前端 未结 1 1634
执念已碎
执念已碎 2020-12-29 09:08

I have the following code in a protocol buffer file(pcfg_lm.proto):

import \"../types/language.proto\";

package nlp;

message PCFGProto {
  required Languag         


        
1条回答
  •  醉梦人生
    2020-12-29 09:35

    You can use the --proto_path= directive to specify which directories to search for imports. It can be used multiple times if needed.

    The correct --proto_path will depend on how the package is defined in the imported file (language.proto).

    1. If the imported file (language.proto) contains package types;

      specify --proto_path=Parent directory and change the import to

      import "types/language.proto";

    2. If the imported file has no package

      specify --proto_path=Parent directory/types and change the import to

      import "language.proto";

    0 讨论(0)
提交回复
热议问题