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 is the equivalent change to encoding/gob as what's proposed in #5901 for encoding/json.
I propose adding the following methods:
// RegisterFunc registers a custom encoder to use for specialized types.// The input f must be a function of the type func(T) ([]byte, error).//// When marshaling a value of type R, the function f is called// if R is identical to T for concrete types or// if R implements T for interface types.// Precedence is given to registered encoders that operate on concrete types,// then registered encoders that operate on interface types// in the order that they are registered, then the specialized marshal methods// (i.e., GobEncode or MarshalBinary), and lastly the default behavior of Encode.//// It panics if T is already registered or if interface{} is assignable to T.func (e*Encoder) RegisterFunc(finterface{})
// RegisterFunc registers a custom decoder to use for specialized types.// The input f must be a function of the type func([]byte, T) error.//// When unmarshaling a value of type R, the function f is called// if R is identical to T for concrete types or// if R implements T for interface types.// Precedence is given to registered decoders that operate on concrete types,// then registered decoders that operate on interface types// in the order that they are registered, then the specialized unmarshal methods// (i.e., GobDecode or UnmarshalBinary), and lastly the default behavior of Decode.//// It panics if T is already registered or if interface{} is assignable to T.func (d*Decoder) RegisterFunc(finterface{})
One such use case for this is to make encoding/gob compatible with higher-order Go types containing protobuf messages.
This is the equivalent change to
encoding/gob
as what's proposed in #5901 forencoding/json
.I propose adding the following methods:
One such use case for this is to make
encoding/gob
compatible with higher-order Go types containing protobuf messages.The text was updated successfully, but these errors were encountered: