简体   繁体   中英

proto file, generated code in python and go

I am trying to generate python and go code using same proto file.

My proto file looks like:

message City {
  string name = 1;
  int32 street_no = 2;
}

When I generate the code in python using below command:

python3 -m grpc_tools.protoc  -I proto/ --python_out=openconfig/ --grpc_python_out=openconfig/ proto/city.proto

then the variables names remain in snake_case, but when the proto file is generatd in go code using below:

${PROTOC} --gogofaster_out=proto --proto_path proto proto/city.proto

then the generated variables are in CamelCase. so, street_no changes to StreetNo

Is there any way to convert the python code also in CamelCase instead of snake_case? How to work in different languages with the same proto file?

I tried with protoc as well as below:

${PROTOC} --python_out=proto --proto_path proto/city.proto

still, it generates the python code in snake_case.

Thanks,

  • M -

Protobufs are generated in the standard formatting of the given language (aka CamelCase for Go and snake_case for Python. If it generated a different way, you would have linter flags for having CamelCase in Python. Is there any reason that the variables need to have the same name in the different languages?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM