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?
Quoting from: https://developers.google.com/protocol-buffers/docs/proto
The
protocol compilersearches 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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With