Questions tagged [protobuf-go]
76 questions
1
vote
0 answers
Can't compile proto file with plugin protoc-gen-go
I had been compiling files with protoc-gen-go and everything went ok, but then i reinstalled Ubuntu, installed protoc again and getting this with same script instead of file:
command:
protoc -I . myfile.proto --go_out=plugins=grpc:protofiles
and…

xmm_581
- 31
- 4
1
vote
0 answers
Reusing Message in the same package in multiple files
Is there a way to reuse protobuf structs across multiple proto files?
in the client.proto file I have the following
message SingleOperation {
string command = 1;
}
message ClientBatch {
string unique_id = 1;
repeated SingleOperation requests…

Pasindu Tennage
- 1,480
- 3
- 14
- 31
1
vote
1 answer
Protobuf message does not implement protoreflect.ProtoMessage (ProtoReflect method has pointer receiver)
I have a Protobuf message that imports "google/protobuf/any.proto":
message MintRecord {
...
google.protobuf.Any data = 11;
...
}
And I am trying to serialize another protobuf inside of the data field using anypb:
data, err :=…

P A S H
- 459
- 1
- 5
- 15
1
vote
1 answer
Protobuf dynamic message schema verification
I'm trying to implement data contract logic.
I've 2 services switching messages with each other.
Service A send messages in some format + the file descriptor proto of the .proto file used to generate it. Service B gets them both, the message and the…

Idan Asulin
- 49
- 3
1
vote
2 answers
Unamed Array - protobuf
I want to receive a list (array) of message using protobuf. The idea would be to receive something like:
[
{
"field1": "value1",
"field2": "value2"
},
{
"field1": "value1",
"field2": "value2"
}
]
However, when defining…

Artur Baruchi
- 11
- 1
1
vote
1 answer
Protobuf oneof type always nil when Unmarshalling
I have a basic protobuf message defined:
syntax = "proto3";
message Order {
string id = 1;
oneof placedby {
string customer_id = 2;
string store_id = 3;
}
}
I'm using kafka to create an event driven system, so when this event is…

Ambellina
- 11
- 2
1
vote
1 answer
Protobuffers and Golang --- writing out marshal'ed structs and reading back in
Is there a generally accepted "correct" way for writing out and reading back in marshaled protocol buffer messages from a file?
I've been working on a smaller project that simulates a full network locally with gRPC and am trying to add writing to/…

mmmeeeker
- 138
- 9
1
vote
2 answers
How to use camelCase JSON tags for marshaling structs in gRPC generated files in Go?
take the struct below as an example,
type Foo struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
IsBar bool …

Ala_b
- 21
- 3
1
vote
1 answer
protobuf validator command generates file in wrong path
I am trying to include request validation for grpc. I modified the protobuf command like this.
pkg/test/test.proto contains my schema.
If i run the below command :
protoc --go_out=. \
--proto_path=${GOPATH}/src…

Prems
- 101
- 11
1
vote
1 answer
Receive protobuf encoded messages that can be partially written?
I am trying to send and receive protobuff encoded messages in GoLang over TCP, where the sender can cancel the write() halfway through the operation, and the receiver can correctly receive partial messages.
Note that I use a single TCP connection to…

Pasindu Tennage
- 1,480
- 3
- 14
- 31
1
vote
1 answer
How to use `protoreflect.Message.Has`?
Given the following proto spec:
message A {
B b = 1;
}
message B {
string s = 1;
}
and an object a of type A, how do I check to see if a.b.s is set? More specifically, how do I create the FieldDescriptor to be passed into Message.Has()?

Noel Yap
- 18,822
- 21
- 92
- 144
1
vote
2 answers
Hash protobuf object to a string as the key for redis database
I have some sort of complex protobuf object. It's a request sent to my GRPC endpoint. I want to just process it if I didn't before. So I want to hash the object to some string and store it in my Redis database. I used ObjectHash-Proto but with new…

s4eed
- 7,173
- 9
- 67
- 104
1
vote
1 answer
Generate .pb file without using protoc in golang
I'm trying to generate .pb.go file using service.proto as file input in Go.
Is there a way to do it without using protoc binary (like directly using package github.com/golang/protobuf/protoc-gen-go)?

abhijit wakchaure
- 390
- 2
- 17
1
vote
0 answers
What do you think about optional as prefix to protobuf field names?
Since proto3, the protobuf spec got rid of the optional and required fields. Now the only way to find out if a field in the message is optional only by looking at the docs, which is not very convenient. How about we use optional_ as the prefix on…

Deepak gupta
- 109
- 1
- 5
1
vote
1 answer
Protobuf generated file doesn't recognize import path
I have a proto file product.proto and I want to use it in catalog.proto. I can successfully import product.proto in catalog.proto but auto-generated catalog.pb.go is not able to reconize the path of its dependency i.e. product.pb.go. It…

Sheraz Sharif
- 11
- 4