protobuf
protobuf copied to clipboard
How to use `M` para
A successful example
I have a project with structure as following:
hello/
`-- protobuf
|-- animal.proto
|-- cat.proto
`-- food
`-- food.proto
The content of proto is:
// cat.proto
import "food/food.proto"
// food.proto
option go_package="hello/protobuf/food"
I run protoc
command in proto
dir:
protoc --proto_path=. \
--go_out=. \
--go_opt=Mfood/food.proto=hello/protobuf/food
cat.proto
Ok, it works fine.
A failed example
I changed the structure as following:
hello/
`-- protobuf
|-- animal.proto
|`--cat
| `--cat.proto
`-- food
`-- food.proto
And the content of proto is:
// cat.proto
import "food/food.proto"
// food.proto
option go_package="hello/protobuf/food"
I run the command in cat
dir,
protoc --proto_path=. \
--go_out=. \
--go_opt=Mfood/food.proto=hello/protobuf/food
cat.proto
So how does the M
para work with proto-gen-go. How should I use it to replace --proto_path
to pass import_path?