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
This occurs only in a oneof block when the name of a field is prefixed with the word get_, which golang protobuf files reserve for the nil safe getter methods, which are produced. Eg. the field request will have a method GetRequest, so the name GetRequest cannot be used by another field.
This file is possible to compile with protoc-gen-go
I've isolated the problem down to this simplified case. I'm only seeing it happen when the field is within a oneof block.
The error message that is produced when compiling example.pb.go
# example
./example.pb.go:99:28: impossible type assertion:
*AnyRequest_GetRequest_ does not implement isAnyRequest_Request (missing MarshalTo method)
./example.pb.go:270:10: undefined: AnyRequest_GetRequest
./example.pb.go:275:10: undefined: AnyRequest_GetRequest
./example.pb.go:383:10: undefined: AnyRequest_GetRequest
./example.pb.go:522:17: undefined: AnyRequest_GetRequest
The issue is with the type signatures for the following methods. MarshalTo, MarshalToSizedBuffer, and Size do not use the alias that the library has chosen for the field. So these methods get defined on a nonexistent type.
If the oneof field has only one field, different error messages are produced. In this case the field is renamed to Request_, but the methods continue to reference the field as Request
./example2.pb.go:183:6: m.Request undefined (type *AnyRequest has no field or method Request)
./example2.pb.go:185:13: m.Request undefined (type *AnyRequest has no field or method Request)
./example2.pb.go:187:18: m.Request undefined (type *AnyRequest has no field or method Request)
./example2.pb.go:260:6: m.Request undefined (type *AnyRequest has no field or method Request)
./example2.pb.go:261:9: m.Request undefined (type *AnyRequest has no field or method Request)
./example2.pb.go:361:5: m.Request undefined (type *AnyRequest has no field or method Request)
This occurs only in a oneof block when the name of a field is prefixed with the word
get_
, which golang protobuf files reserve for the nil safe getter methods, which are produced. Eg. the fieldrequest
will have a methodGetRequest
, so the nameGetRequest
cannot be used by another field.This file is possible to compile with
protoc-gen-go
I've isolated the problem down to this simplified case. I'm only seeing it happen when the field is within a
oneof
block.The error message that is produced when compiling
example.pb.go
The issue is with the type signatures for the following methods. MarshalTo, MarshalToSizedBuffer, and Size do not use the alias that the library has chosen for the field. So these methods get defined on a nonexistent type.
The text was updated successfully, but these errors were encountered: