commit | 2cdb23da0126477dd395294c0714e8ee6fb8c79b | [log] [tgz] |
---|---|---|
author | Joe Tsai <joetsai@digital-static.net> | Fri Nov 09 16:32:36 2018 -0800 |
committer | Joe Tsai <thebrokentoaster@gmail.com> | Sat Nov 10 00:59:49 2018 +0000 |
tree | a4d93dc2a22b1e58ea4334f5712ee901b506ec59 | |
parent | 34eb7ef6d5127078404b6d6ae5ef8fc6b4b25984 [diff] |
reflect/prototype: remove TODO about custom extensions constructors Most usages extensions are only for fields that have a singular message as the type. In such a sitation, the Go type and constructors are determined by the provided protoreflect.MessageType and is certainly what the user wanted. Custom extensions constructors are mainly useful if the user wants to use their own type to represent repeated fields. For example, we use *[]T to represent repeated fields, while a user may want to use their own opaque type. However, this is such a niche use-case that it is not worth supporting given that there is a workaround: type MyExtensionType struct { protoreflect.ExtensionType } func (x MyExtensionType) GoNew() interface{} { ... // return my custom value } func (x MyExtensionType) GoType() reflect.Type { ... // return my custom type } func (x MyExtensionType) ValueOf(v interface{}) protoreflect.Value { ... // convert my custom type to a protoreflect.Value } func (x MyExtensionType) InterfaceOf(v protoreflect.Value) interface{} { ... // convert a protoreflect.Value to my custom type } Change-Id: Iafc838b1c95b0ffc8583461ee9eb327bd3ce9c3c Reviewed-on: https://go-review.googlesource.com/c/148820 Reviewed-by: Herbie Ong <herbie@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.