Documentation ¶
Overview ¶
Package marshaling provides utilities for marshaling and unmarshaling messages and other types.
Index ¶
- Constants
- func MarshalJSON(msg proto.Message) (ct string, data []byte, err error)
- func MarshalProtobuf(m proto.Message) (ct string, data []byte, err error)
- func MarshalTime(t time.Time) string
- func Unmarshal(ct string, data []byte) (proto.Message, error)
- func UnmarshalJSON(ct string, data []byte) (proto.Message, error)
- func UnmarshalJSONParams(ctn string, p map[string]string, data []byte) (proto.Message, error)
- func UnmarshalProtobuf(ct string, data []byte) (proto.Message, error)
- func UnmarshalProtobufParams(ctn string, p map[string]string, data []byte) (proto.Message, error)
- func UnmarshalTime(s string, t *time.Time) error
Constants ¶
const (
// JSONContentType is the content-type name for JSON-encoded messages.
JSONContentType = "application/json"
)
const (
// ProtobufContentType is the content-type name for protocol buffer messages.
ProtobufContentType = "application/vnd.google.protobuf"
)
Variables ¶
This section is empty.
Functions ¶
func MarshalJSON ¶
MarshalJSON marshals a ProtocolBuffers message to its JSON representation and returns a MIME content-type that identifies the particular message protocol.
func MarshalProtobuf ¶
MarshalProtobuf marshals a ProtocolBuffers message to its binary representation and returns a MIME content-type that identifies the particular message protocol.
func MarshalTime ¶
MarshalTime marshals t to an RFC3339+Nano string.
func Unmarshal ¶
Unmarshal unmarshals a protocol buffers message from some serialized representation. ct is the MIME content-type for the binary data.
func UnmarshalJSON ¶
UnmarshalJSON unmarshals a ProtocolBuffers message from its JSON representation using an unparsed MIME content-type to identify the particular message protocol.
func UnmarshalJSONParams ¶
UnmarshalJSONParams unmarshals a JSON-encoded message using a pre-parsed MIME content-type to identify the particular message protocol.
ctn is the MIME content-type name, p is the set of pre-parsed content-type parameters, as returned by mime.ParseMediaType().
func UnmarshalProtobuf ¶
UnmarshalProtobuf unmarshals a ProtocolBuffers message from its binary representation using an unparsed MIME content-type to identify the particular message protocol.
func UnmarshalProtobufParams ¶
UnmarshalProtobufParams unmarshals a ProtocolBuffers messages from its binary representation using a pre-parsed MIME content-type to identify the particular message protocol.
ctn is the MIME content-type name, p is the set of pre-parsed content-type parameters, as returned by mime.ParseMediaType().
Types ¶
This section is empty.