package runtimeimport ()// ProtoMarshaller is a Marshaller which marshals/unmarshals into/from serialize proto bytestypeProtoMarshallerstruct{}// ContentType always returns "application/octet-stream".func (*ProtoMarshaller) ( interface{}) string {return"application/octet-stream"}// Marshal marshals "value" into Protofunc (*ProtoMarshaller) ( interface{}) ([]byte, error) { , := .(proto.Message)if ! {returnnil, errors.New("unable to marshal non proto field") }returnproto.Marshal()}// Unmarshal unmarshals proto "data" into "value"func (*ProtoMarshaller) ( []byte, interface{}) error { , := .(proto.Message)if ! {returnerrors.New("unable to unmarshal non proto field") }returnproto.Unmarshal(, )}// NewDecoder returns a Decoder which reads proto stream from "reader".func ( *ProtoMarshaller) ( io.Reader) Decoder {returnDecoderFunc(func( interface{}) error { , := io.ReadAll()if != nil {return }return .Unmarshal(, ) })}// NewEncoder returns an Encoder which writes proto stream into "writer".func ( *ProtoMarshaller) ( io.Writer) Encoder {returnEncoderFunc(func( interface{}) error { , := .Marshal()if != nil {return }if , := .Write(); != nil {return }returnnil })}
The pages are generated with Goldsv0.8.2. (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu.
PR and bug reports are welcome and can be submitted to the issue list.
Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds.