Given a
message Foo {
enum State {
STATE1 = 0;
STATE2 = 1;
STATE3 = 2;
}
}
and a grpc service definition of
rpc Method(stream Foo) returns (Empty) {}
What does the go grpc client code to send this to a grpc server look like? To clarify, suppose I have a streamClient.Send()
. What would I pass to Send()
? How do I construct the enum?
You define State but you do not have a State field in Foo.
Try this
syntax="proto3";
option go_package ="enumpb";
message Foo {
enum State {
STATE1 = 0;
STATE2 = 1;
STATE3 = 2;
}
State myState = 1;
}
And this in go
enumExample := enumpb.Foo{
MyState: enumpb.Foo_STATE1,
}
fmt.Println("enumExample", enumExample)