/tmp/TestABCMessage_in_version_abc_test_gogo -test.v -test.run
^TestABCMessage$
(*errors.errorString)(0xc420214af0)(proto: not an extendable proto)
(interface {}) <nil>
On Wednesday, October 25, 2017 at 8:38:51 PM UTC+8, [email protected]
wrote:
>
> the example in
> https://developers.google.com/protocol-buffers/docs/proto#customoptions
> below
>
> message FooOptions {
> optional int32 opt1 = 1;
> optional string opt2 = 2;
> }
>
> extend google.protobuf.FieldOptions {
> optional FooOptions foo_options = 1234;
> }
>
> // usage:
> message Bar {
> optional int32 a = 1 [(foo_options).opt1 = 123, (foo_options).opt2 = "baz"];
> // alternative aggregate syntax (uses TextFormat):
> optional int32 b = 2 [(foo_options) = { opt1: 456 opt2: "xaa" }];
> }
>
> assume I have a message Bar here:
>
> var msg Bar
> _, md := ForMessage(&msg)
> md.Field[0].GetOptions().String() only a string, How do i parse that ??
>
> How to I get the exact value of Bar.b.opt1 which is 123 (default value)
>
> What I want is like this
>
> md.Field[0].GetOptions().GetOpt1() // 123
> md.Field[0].GetOptions().GetOpt2() // baz
> md.Field[1].GetOptions().GetOpt1() // 456
> md.Field[1].GetOptions().GetOpt2() // xaa
>
> Can we achieve that ?
>
--
You received this message because you are subscribed to the Google Groups
"Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/d/optout.