AttributeError: Assignment not allowed to composite field “task” in protocol message object
Try CopyFrom: ptask.task.CopyFrom(task)
Try CopyFrom: ptask.task.CopyFrom(task)
Protocol Buffers does not support inheritance. Instead, consider using composition: message Foo { Bar bar = 1; string id = 2; } However, that said, there is a trick you can use which is like inheritance — but which is an ugly hack, so you should only use it with care. If you define your … Read more
protoc-gen-go needs to be in your shell path, i.e. one of the directories listed in the PATH environment variable, which is different from the Go path. You can test this by simply typing protoc-gen-go at the command line: If it says “command not found” (or similar) then it’s not in your PATH.
Tannisha Hill indicated that the following package had to be added: sudo apt install protobuf-compiler In my case, I also had to add this one: sudo apt install golang-goprotobuf-dev
You should probably use string or bytes to represent a UUID. Use string if it is most convenient to keep the UUID in human-readable format (e.g. “de305d54-75b4-431b-adb2-eb6b9e546014”) or use bytes if you are storing the 128-bit value raw. (If you aren’t sure, you probably want string.) Wrapping the value in a message type called UUID … Read more
As mentioned in an answer to a similar question, since v3.1.0 this is a supported feature of ProtocolBuffers. For Java, include the extension module com.google.protobuf:protobuf-java-util and use JsonFormat like so: JsonFormat.parser().ignoringUnknownFields().merge(json, yourObjectBuilder); YourObject value = yourObjectBuilder.build();
Disclaimer: Answer from a Googler using protobufs on a daily basis. I’m by no means representing Google in any way. Name your proto Person instead of PersonProto or ProtoPerson. Compiled protobufs are just class definitions specified by the language you are using, with some improvements. Adding “Proto” is extra verbosity. Use YourMessage.hasYourField() instead of YourMessage.getYourField() … Read more
My understanding is that proto3 no longer allows you to detect field presence and no longer supports non-zero default values because this makes it easier to implement protobufs in terms of “plain old structs” in various languages, without the need to generate accessor methods. This is perceived as making Protobuf easier to use in those … Read more
Assuming the generated python is located in File_pb2.py code Try this: file_pb2._TEST.values_by_number[1].name In your case, this should give ‘ONE’ The reverse is : file_pb2._TEST.values_by_name[‘ONE’].number will give 1. EDIT: As correctly pointed by @dyoo in the comments, a new method was later introduced in protobuf library: file_pb2.Test.Name(1) file_pb2.Test.Value(‘One’) EDIT: This has changed again in proto3. Now … Read more
sudo ldconfig or export LD_LIBRARY_PATH=/usr/local/lib should solve the problem.