mirror of
https://github.com/protocolbuffers/protobuf-go.git
synced 2025-01-04 02:38:50 +00:00
23ccb359e1
Implement support in the protobuf runtime to better understand message types that are not generated by the official generator. In particular: * Add a best-effort implementation of protobuf reflection for "non-nullable" fields which are supposed to be represented by *T, but are instead represented by a T. "Non-nullable" message fields report presence based on whether the message is the zero Go value. * We do NOT implement support for "non-nullable" fields in the table-driven implementation since we assume that the aberrant messages that we care about have a Marshal and Unmarshal method. * We better handle custom messages that implement Marshal and Unmarshal, but do NOT implement Merge. In that case, we implement merge in terms of a back-to-back marshal and unmarshal. * We better tolerate the situations where a protobuf message field cannot be mapped to a Go struct field since the latter is missing. In such cases, reflection treats the field as if it were unpopulated. Setting such fields will panic. This change allows the runtime to handle all message types declared in the "go.etcd.io/etcd" and "k8s.io" modules where protobuf reflection, Marshal, Unmarshal, Reset, Merge, and Equal all work. The only types that still do not fully work are: * "k8s.io/api/authentication/v1".ExtraValue * "k8s.io/api/authentication/v1beta1".ExtraValue * "k8s.io/api/authorization/v1".ExtraValue * "k8s.io/api/authorization/v1beta1".ExtraValue * "k8s.io/api/certificates/v1".ExtraValue * "k8s.io/api/certificates/v1beta1".ExtraValue * "k8s.io/apimachinery/pkg/apis/meta/v1".MicroTime * "k8s.io/apimachinery/pkg/apis/meta/v1".Time * "k8s.io/apimachinery/pkg/apis/meta/v1".Verbs While Marshal, Unmarshal, Reset, and Merge continue to work, protobuf reflection and any functionality that depends on it (e.g., prototext, protojson, Equal, etc.) will not work. Change-Id: I67a9d2f1bec35248045ad0c16220d02fc2e0e172 Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/300869 Trust: Joe Tsai <joetsai@digital-static.net> Trust: Joe Tsai <thebrokentoaster@gmail.com> Reviewed-by: Damien Neil <dneil@google.com> |
||
---|---|---|
.. | ||
api_export.go | ||
checkinit.go | ||
codec_extension.go | ||
codec_field.go | ||
codec_gen.go | ||
codec_map_go111.go | ||
codec_map_go112.go | ||
codec_map.go | ||
codec_message.go | ||
codec_messageset.go | ||
codec_reflect.go | ||
codec_tables.go | ||
codec_unsafe.go | ||
convert_list.go | ||
convert_map.go | ||
convert.go | ||
decode.go | ||
encode.go | ||
enum_test.go | ||
enum.go | ||
extension_test.go | ||
extension.go | ||
lazy_test.go | ||
legacy_aberrant_test.go | ||
legacy_enum.go | ||
legacy_export_test.go | ||
legacy_export.go | ||
legacy_extension.go | ||
legacy_file_test.go | ||
legacy_file.go | ||
legacy_message.go | ||
legacy_test.go | ||
merge_gen.go | ||
merge.go | ||
message_reflect_field.go | ||
message_reflect_gen.go | ||
message_reflect_test.go | ||
message_reflect.go | ||
message.go | ||
pointer_reflect.go | ||
pointer_unsafe.go | ||
validate.go | ||
weak.go |