You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am attempting to extend my proto files using a custom option. However, when parsing out the option from the AST using getUninterpretedOptions, I get an empty array. Serializing it with .String() does however return what you would expect.
// Definition of the `build.info` custom optionextendgoogle.protobuf.MethodOptions {
Runtimeprotoflow=1;
}
// Definition of the `BuildMetadata` message used in `build.info`messageRuntime {
stringname=1;
}
// Trying to use the option
rpc ExternalMethod (google.protobuf.Empty) returns (MethodOneResponse) {
option(protoflow)= {
name: "External Method",
};
};
And here is the line that is returning an empty array
funcTestParseProto(t*testing.T) {
res, err:=ParseProto("")
iferr!=nil {
t.Fatal(err)
}
m:=map[string]interface{}{}
for_, r:=rangeres {
buildUninterpretedMapForFile(r.GetFile(), m)
for_, s:=ranger.GetServices() {
t.Log(s.GetFullyQualifiedName())
for_, m:=ranges.GetMethods() {
t.Log(m.GetFullyQualifiedName())
mo:=m.GetMethodOptions()
// ------- THIS IS RETURNING EMPTY ARRAY --------mo.GetUninterpretedOption()
// But this .String method IS returning the serialized message properlyt.Log(mo.String())
for_, o:=rangemo.GetUninterpretedOption() {
for_, n:=rangeo.GetName() {
t.Log(n)
}
}
}
}
}
}
Here is the full parser code in case more context is needed
go test -v
# b1547 [b1547.test]
./repro_test.go:14:14: undefined: ParseProto
Can you please provide steps to reproduce that are complete and tested?
Also, I noticed your code is importing github.com/jhump/protoreflect, which is a third-party parser that is not supported by the Go Protobuf maintainers. Can you reproduce your issue with only the official Go Protobuf packages? If not, you should probably file an issue with github.com/jhump/protoreflect instead.
I am attempting to extend my proto files using a custom option. However, when parsing out the option from the AST using
getUninterpretedOptions
, I get an empty array. Serializing it with .String() does however return what you would expect.And here is the line that is returning an empty array
Here is the full parser code in case more context is needed
https://gist.github.com/factoidforrest/95ded881160638dbb024de43dd764b93
Does anyone have any sample code of parsing and using custom options with this library?
The text was updated successfully, but these errors were encountered: