Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the -I f lag in protoc tool for Protocol Buffers?

The -I flag in protoc cli is not documented i.e. protoc --help does not list it in libprotoc 3.13.0

protoc -I src/ --go_out=src/ src/proto/greet/greetpb/greet.proto 

Yet I see many people use it. Can someone explain the -I flag?

like image 504
Subtubes Avatar asked Oct 18 '25 15:10

Subtubes


1 Answers

Quoting from: https://developers.google.com/protocol-buffers/docs/proto

The protocol compiler searches for imported files in a set of directories specified on the protocol compiler command line using the -I/--proto_path flag. If no flag was given, it looks in the directory in which the compiler was invoked. In general you should set the --proto_path flag to the root of your project and use fully qualified names for all imports.

Clunky code-style highlights by me.

That protocol compiler is of course the protoc tool.

So, it seems it's an alias for proto_path, a kind of search-directory, like all compilers tend to have, for looking up imported files. Think C++ and #include lookup paths, Java and classpath, and so on.

like image 106
quetzalcoatl Avatar answered Oct 22 '25 04:10

quetzalcoatl



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!