commit | 812d9137dfe746dc679874e16e3d9f2287313733 | [log] [tgz] |
---|---|---|
author | Joe Tsai <joetsai@digital-static.net> | Wed Sep 12 11:26:15 2018 -0700 |
committer | Joe Tsai <thebrokentoaster@gmail.com> | Thu Sep 13 19:52:11 2018 +0000 |
tree | d0694dd3cce2aebb061d6515dd55a397c27e1e10 | |
parent | ebc699d09917d3b867eb08fe8470657c3a355592 [diff] |
reflect/protoreflect: add Has and Clear to KnownFields and Map Change the API to use explicit Has/Clear methods instead of relying on the "invalid" form of Value to represent nullability. There are several reasons for this change: * Much of the ecosystem around protobufs do not care about nullability alone. For example, for the encoder to determine whether to emit a field: it needs to first check if a field is nulled, and if not, it still needs to go through a series of type-assertion to check whether the value is the zero value. It is much easier to be able to just call Has. * It enables representing the default value as part of the value API, rather than only as part of the descriptor API. * The C++ API also uses explicit has and clear methods. However, we differ from them by defining Has for proto3 scalars (while C++ panics instead). For internal consistency, we also use a Has/Clear API for Maps. Change-Id: I30eda482c959d3e1454d72d9fc761c761ace27a6 Reviewed-on: https://go-review.googlesource.com/134998 Reviewed-by: Damien Neil <dneil@google.com>
WARNING: This repository is in active development. There are no guarantees about API stability. Breaking changes will occur until a stable release is made and announced.
This repository is for the development of the next major Go implementation of protocol buffers. This library makes breaking API changes relative to the existing Go protobuf library. Of particular note, this API aims to make protobuf reflection a first-class feature of the API and implements the protobuf ecosystem in terms of reflection.
List of relevant design documents:
We appreciate community contributions. See CONTRIBUTING.md.
Issues regarding the new API can be filed at github.com/golang/protobuf. Please use a APIv2:
prefix in the title to make it clear that the issue is regarding the new API work.